From 6ebd84831ecb68e929eb3ceff7a8d41687489c76 Mon Sep 17 00:00:00 2001 From: Henry Castro Date: Wed, 16 Mar 2022 12:11:52 -0400 Subject: [PATCH] infobar: show message every five days Change-Id: Iedf6aff2f026f4530bfed06cd4bf5e7acae15a50 Signed-off-by: Henry Castro --- browser/src/map/handler/Map.Infobar.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/browser/src/map/handler/Map.Infobar.js b/browser/src/map/handler/Map.Infobar.js index 55198b221..e084c3673 100644 --- a/browser/src/map/handler/Map.Infobar.js +++ b/browser/src/map/handler/Map.Infobar.js @@ -16,7 +16,19 @@ L.Map.Infobar = L.Handler.extend({ if (viewInfo && !this.enabled() && viewInfo.userextrainfo && viewInfo.userextrainfo.is_admin) { - this.enable(); + var laterDate = new Date(); + var currentDate = new Date(); + var timeValue = window.localStorage.getItem('InfoBarLaterDate'); + if (!timeValue || isNaN(timeValue)) { + /* - 5 seconds */ + laterDate.setTime(currentDate.getTime() - 5000); + } else { + /* + 5 days (432,000,000 Milliseconds) */ + laterDate.setTime(timeValue + 432000000); + } + + if (currentDate > laterDate) + this.enable(); } }, @@ -62,6 +74,8 @@ L.Map.Infobar = L.Handler.extend({ var data = e.data; if (data === 'updatecheck-show') { + var currentDate = new Date(); + window.localStorage.setItem('InfoBarLaterDate', currentDate.getTime()); this._iframeInfobar.show(); } else if (data === 'updatecheck-close') { this._map.infobar.disable();