From df9f2c9c293af7343b7f547132d4f82b5771b5f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Benqu=C3=A9?= Date: Mon, 9 Dec 2019 11:14:05 +0000 Subject: [PATCH] dismiss warning about sharing links - remember if warning has been dismissed - include this in tips that can be reset - move the option to reset tips to the account settings --- www/common/common-ui-elements.js | 52 +++++++++++++++++++++++++++----- www/settings/inner.js | 4 +-- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 9338471a7..46befaac2 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -1092,10 +1092,29 @@ define([ ])); } - linkContent.push(h('div.alert.alert-warning.dismissable', [ - h('span.cp-inline-alert-text', Messages.share_linkWarning), - h('span.fa.fa-times') // XXX dismiss message and remember - ])); + // warning about sharing links + var localStore = window.cryptpadStore; + var dismissButton = h('span.fa.fa-times'); + var shareLinkWarning = h('div.alert.alert-warning.dismissable', + { style: 'display: none;' }, + [ + h('span.cp-inline-alert-text', Messages.share_linkWarning), + dismissButton + ]); + linkContent.push(shareLinkWarning); + + localStore.get('hide-alert-shareLinkWarning', function (val) { + if (val === '1') { return; } + $(shareLinkWarning).show(); + + $(dismissButton).on('click', function () { + localStore.put('hide-alert-shareLinkWarning', '1'); + $(shareLinkWarning).remove(); + }); + + }); + + var link = h('div.cp-share-modal', linkContent); var $link = $(link); @@ -1347,10 +1366,27 @@ define([ ])); } - linkContent.push(h('div.alert.alert-warning.dismissable', [ - h('span.cp-inline-alert-text', Messages.share_linkWarning), - h('span.fa.fa-times') // XXX dismiss message and remember - ])); + // warning about sharing links + var localStore = window.cryptpadStore; + var dismissButton = h('span.fa.fa-times'); + var shareLinkWarning = h('div.alert.alert-warning.dismissable', + { style: 'display: none;' }, + [ + h('span.cp-inline-alert-text', Messages.share_linkWarning), + dismissButton + ]); + linkContent.push(shareLinkWarning); + + localStore.get('hide-alert-shareLinkWarning', function (val) { + if (val === '1') { return; } + $(shareLinkWarning).show(); + + $(dismissButton).on('click', function () { + localStore.put('hide-alert-shareLinkWarning', '1'); + $(shareLinkWarning).remove(); + }); + + }); var link = h('div.cp-share-modal', linkContent); diff --git a/www/settings/inner.js b/www/settings/inner.js index d67f62818..7c9dd0630 100644 --- a/www/settings/inner.js +++ b/www/settings/inner.js @@ -51,6 +51,7 @@ define([ 'cp-settings-info-block', 'cp-settings-displayname', 'cp-settings-language-selector', + 'cp-settings-resettips', 'cp-settings-logout-everywhere', 'cp-settings-autostore', 'cp-settings-userfeedback', @@ -67,7 +68,6 @@ define([ ], 'drive': [ 'cp-settings-drive-duplicate', - 'cp-settings-resettips', 'cp-settings-thumbnails', 'cp-settings-drive-backup', 'cp-settings-drive-import-local', @@ -835,7 +835,7 @@ define([ var localStore = window.cryptpadStore; $button.click(function () { Object.keys(localStore.store).forEach(function (k) { - if(k.slice(0, 9) === "hide-info") { + if(/^(hide-(info|alert))/.test(k)) { localStore.put(k, null); } });