From 814c81fb13f987ce76bf2be1ff0fb421a77a899e Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 18 May 2017 18:51:08 +0200 Subject: [PATCH 1/2] Display an alert when CryptPad has a new version --- customize.dist/translations/messages.fr.js | 4 ++++ customize.dist/translations/messages.js | 4 ++++ www/common/cryptpad-common.js | 23 +++++++++++++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 26cfc3129..e8cc86ce2 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -54,6 +54,10 @@ define(function () { out.comingSoon = "Bientôt disponible..."; + out.newVersion = 'CryptPad a été mis à jour !
' + + 'Découvrez les nouveautés de la dernière version :
'+ + 'Notes de version pour CryptPad {0}'; + out.upgrade = "Améliorer"; out.upgradeTitle = "Améliorer votre compte pour augmenter la limite de stockage"; out.MB = "Mo"; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index dcafe6283..6280a5732 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -56,6 +56,10 @@ define(function () { out.comingSoon = "Coming soon..."; + out.newVersion = 'CryptPad has been updated!
' + + 'Check out what\'s new in the latest version:
'+ + 'Release notes for CryptPad {0}'; + out.upgrade = "Upgrade"; out.upgradeTitle = "Upgrade your account to increase the storage limit"; out.MB = "MB"; diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 14f0a8b66..2f4cdf8e5 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -23,7 +23,6 @@ define([ Additionally, there is some basic functionality for import/export. */ - var common = window.Cryptpad = { Messages: Messages, Clipboard: Clipboard @@ -1296,6 +1295,25 @@ define([ return $userAdmin; }; + var CRYPTPAD_VERSION = 'cryptpad-version'; + var updateLocalVersion = function () { + // Check for CryptPad updates + var urlArgs = Config.requireConf ? Config.requireConf.urlArgs : null; + if (!urlArgs) { return; } + var arr = /ver=([0-9.]+)(-[0-9]*)?/.exec(urlArgs); + var ver = arr[1]; + if (!ver) { return; } + var verArr = ver.split('.'); + if (verArr.length !== 3) { return; } + var stored = localStorage[CRYPTPAD_VERSION] || '0.0.0'; + var storedArr = stored.split('.'); + var shouldUpdate = parseInt(verArr[0]) > parseInt(storedArr[0]) || + (parseInt(verArr[0]) === parseInt(storedArr[0]) && + parseInt(verArr[1]) > parseInt(storedArr[1])); + if (!shouldUpdate) { return; } + Cryptpad.alert(Messages._getKey('newVersion', [ver]), null, true); + localStorage[CRYPTPAD_VERSION] = ver; + }; common.ready = (function () { var env = {}; @@ -1313,6 +1331,9 @@ define([ block--; if (!block) { initialized = true; + + updateLocalVersion(); + f(void 0, env); } }; From d014fccfce1f89d19be59b4965de4151833091df Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 18 May 2017 18:52:14 +0200 Subject: [PATCH 2/2] Fix lint error --- www/common/cryptpad-common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 485bf2f44..6f0a5e256 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -1311,7 +1311,7 @@ define([ (parseInt(verArr[0]) === parseInt(storedArr[0]) && parseInt(verArr[1]) > parseInt(storedArr[1])); if (!shouldUpdate) { return; } - Cryptpad.alert(Messages._getKey('newVersion', [ver]), null, true); + common.alert(Messages._getKey('newVersion', [ver]), null, true); localStorage[CRYPTPAD_VERSION] = ver; };