1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-11-18 16:25:13 +00:00

BrowserStorage: Add startup log and fix save filter

The previous filter was rejecting tiddlers that needed to be deleted.
This commit is contained in:
Jermolene
2019-02-07 17:59:55 +00:00
parent adb07ccba0
commit 2c37c25c28
5 changed files with 33 additions and 6 deletions

View File

@@ -23,7 +23,8 @@ if(Object.prototype.hasOwnProperty.call($tw.hooks.names,hookName)) {
// Load tiddlers from browser storage
function hookBootTiddlersLoaded() {
var url = window.location.protocol === "file:" ? window.location.pathname : "";
var url = window.location.protocol === "file:" ? window.location.pathname : "",
log = [];
// Step through each browsder storage item
for(var index=0; index<window.localStorage.length; index++) {
var key = window.localStorage.key(index),
@@ -47,15 +48,19 @@ function hookBootTiddlersLoaded() {
if(existingTiddler && existingTiddler.isEqual(incomingTiddler)) {
// If the incoming tiddler is the same as the existing then we can delete the local storage version
window.localStorage.removeItem(key);
console.log("Removing from local storage",title)
}
$tw.wiki.addTiddler(incomingTiddler);
console.log("Loading from local storage",title);
log.push(title);
}
}
}
}
}
// Save the log
$tw.wiki.addTiddler({
title: "$:/temp/BrowserStorage/Log",
text: $tw.utils.stringifyList(log)
});
}
})();