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); } };