diff --git a/customize.dist/src/less/toolbar.less b/customize.dist/src/less/toolbar.less index 5d2db90af..73cce9923 100644 --- a/customize.dist/src/less/toolbar.less +++ b/customize.dist/src/less/toolbar.less @@ -56,6 +56,9 @@ margin-left: 5px; } } + &.hidden { + display: none; + } } .cryptpad-lag { diff --git a/customize.dist/toolbar.css b/customize.dist/toolbar.css index 7c5052bfc..de846b7bd 100644 --- a/customize.dist/toolbar.css +++ b/customize.dist/toolbar.css @@ -128,6 +128,9 @@ .cryptpad-toolbar button#shareButton .large { margin-left: 5px; } +.cryptpad-toolbar button.hidden { + display: none; +} .cryptpad-toolbar .cryptpad-lag { box-sizing: content-box; height: 16px; diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 93d610c1c..c32ebbe10 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -581,6 +581,21 @@ define([ }; // STORAGE + var isNotStrongestStored = common.isNotStrongestStored = function (href, recents) { + var parsed = parsePadUrl(href); + return recents.some(function (pad) { + var p = parsePadUrl(pad.href); + if (p.type !== parsed.type) { return false; } // Not the same type + if (p.hash === parsed.hash) { return false; } // Same hash, not stronger + var pHash = parseHash(p.hash); + var parsedHash = parseHash(parsed.hash); + if (pHash.version !== parsedHash.version) { return false; } + if (pHash.channel !== parsedHash.channel) { return false; } + if (pHash.mode === 'edit' && parsedHash.mode === 'view') { return true; } + if (pHash.mode === parsedHash.mode && parsedHash.present) { return true; } + return false; + }); + }; var setPadTitle = common.setPadTitle = function (name, cb) { var href = window.location.href; var parsed = parsePadUrl(href); @@ -893,6 +908,11 @@ define([ 'class': "fa fa-trash cryptpad-forget", style: 'font:'+size+' FontAwesome' }); + getRecentPads(function (err, recent) { + if (isNotStrongestStored(window.location.href, recent)) { + button.addClass('hidden'); + } + }); if (callback) { button.click(function() { var href = window.location.href; @@ -1067,7 +1087,8 @@ define([ var createLanguageSelector = common.createLanguageSelector = function ($container, $initBlock) { var options = []; var languages = Messages._languages; - for (var l in languages) { + var keys = Object.keys(languages).sort(); + keys.forEach(function (l) { options.push({ tag: 'a', attributes: { @@ -1077,7 +1098,7 @@ define([ }, content: languages[l] // Pretty name of the language value }); - } + }); var dropdownConfig = { text: Messages.language, // Button initial text options: options, // Entries displayed in the menu