From a5ac5ddd16d8c992a5fe5748048272d5bfd22c1e Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Tue, 26 Jan 2021 10:32:03 +0200 Subject: [PATCH] Show changelog notification --- assets/js/app.js | 40 +++++++++---------- .../templates/layout/app.html.eex | 2 +- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index 4232f5968..92d535cce 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -70,27 +70,23 @@ function showChangelogNotification(el) { const lastUpdated = Number(localStorage.lastChangelogUpdate) const lastChecked = Number(localStorage.lastChangelogClick) - if (lastChecked) { - const hasNewUpdateSinceLastClicked = lastUpdated > lastChecked - const notOlderThanThreeDays = Date.now() - lastUpdated < 1000 * 60 * 60 * 72 - if (hasNewUpdateSinceLastClicked && notOlderThanThreeDays) { - el.innerHTML = ` - - - - - - - - - ` - const link = el.getElementsByTagName('a')[0] - link.addEventListener('click', function() { - localStorage.lastChangelogClick = Date.now() - setTimeout(() => { link.remove() }, 100) - }) - } - } else { - localStorage.lastChangelogClick = Date.now() + const hasNewUpdateSinceLastClicked = lastUpdated > lastChecked + const notOlderThanThreeDays = Date.now() - lastUpdated < 1000 * 60 * 60 * 72 + if ((!lastChecked || hasNewUpdateSinceLastClicked) && notOlderThanThreeDays) { + el.innerHTML = ` + + + + + + + + + ` + const link = el.getElementsByTagName('a')[0] + link.addEventListener('click', function() { + localStorage.lastChangelogClick = Date.now() + setTimeout(() => { link.remove() }, 100) + }) } } diff --git a/lib/plausible_web/templates/layout/app.html.eex b/lib/plausible_web/templates/layout/app.html.eex index 1a1f944f9..621f78391 100644 --- a/lib/plausible_web/templates/layout/app.html.eex +++ b/lib/plausible_web/templates/layout/app.html.eex @@ -58,7 +58,7 @@ - <%= if @conn.assigns[:current_user].email in ["hi@markosaric.com", "uku@plausible.io"] do %> + <%= if @conn.assigns[:current_user] do %>
  • <% end %>