diff --git a/boot/boot.js b/boot/boot.js index ae9188c01..dd3b27185 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -556,8 +556,12 @@ $tw.utils.Crypto = function() { this.updateCryptoStateTiddler(); }; this.updateCryptoStateTiddler = function() { - if($tw.wiki && $tw.wiki.addTiddler) { - $tw.wiki.addTiddler(new $tw.Tiddler({title: "$:/isEncrypted", text: currentPassword ? "yes" : "no"})); + if($tw.wiki) { + var state = currentPassword ? "yes" : "no", + tiddler = $tw.wiki.getTiddler("$:/isEncrypted"); + if(!tiddler || tiddler.fields.text !== state) { + $tw.wiki.addTiddler(new $tw.Tiddler({title: "$:/isEncrypted", text: state})); + } } }; this.hasPassword = function() { diff --git a/core/modules/startup.js b/core/modules/startup.js index 615959cba..81aaca530 100755 --- a/core/modules/startup.js +++ b/core/modules/startup.js @@ -157,6 +157,12 @@ exports.startup = function() { $tw.rootWidget.addEventListener("tw-clear-password",function(event) { $tw.crypto.setPassword(null); }); + // Ensure that $:/isEncrypted is maintained properly + $tw.wiki.addEventListener("change",function(changes) { + if($tw.utils.hop(changes,"$:/isEncrypted")) { + $tw.crypto.updateCryptoStateTiddler(); + } + }); // Set up the favicon var faviconTitle = "$:/favicon.ico", faviconLink = document.getElementById("faviconLink"),