mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-30 16:00:46 +00:00
BrowserStoragePlugin: Do not save shadow tiddlers to local storage (#7365)
If a tiddler is only a shadow tiddler, then do not save it to local storage. Otherwise when installing a plugin, each individual tiddler will be expanded and saved individually. In order to uninstall such a plugin, the plugin tiddler and each tiddler needs to be deleted. This can be prevented by including a run like `-[is[shadow]!is[tiddler]]` in the save filter, but that has the side effect of preventing overwritten shadow tiddlers from being deleted from local storage.
This commit is contained in:
parent
a6ced74a13
commit
3ee5f10362
@ -17,8 +17,8 @@ Click this button to clear browser storage and disable its use:
|
|||||||
This filter determines which tiddlers will be saved to local storage.
|
This filter determines which tiddlers will be saved to local storage.
|
||||||
|
|
||||||
* `[prefix[$:/state/]] -[prefix[$:/state/popup/]]` - the default value. Save state tiddlers except popup state tiddlers, thus preserving selected tabs and the open/closed status of table of contents entries. Any other tiddlers created or changed will be lost after reloading the page.
|
* `[prefix[$:/state/]] -[prefix[$:/state/popup/]]` - the default value. Save state tiddlers except popup state tiddlers, thus preserving selected tabs and the open/closed status of table of contents entries. Any other tiddlers created or changed will be lost after reloading the page.
|
||||||
* `[all[]]` - attempt to save all changed tiddlers. This means even popup state tiddlers and temporary tiddlers will be saved. In addition, when a plugin is installed, all the shadow tiddlers are individually "exploded" into local storage. Deleting the plugin requires deleting all the tiddlers individually. Not recommended unless these issues are unimportant.
|
* `[all[]]` - attempt to save all changed tiddlers. This means even popup state tiddlers and temporary tiddlers will be saved.
|
||||||
* `[all[]] -[is[shadow]!is[tiddler]] -[prefix[$:/state/popup/]] -[prefix[$:/temp/]] -[prefix[$:/HistoryList]]` - save all tiddlers except unmodified shadow tiddlers, popup state tiddlers, temp tiddlers and the history list. Solves the aforementioned issues with `[all[]]`. Recommended.
|
* `[all[]] -[prefix[$:/state/popup/]] -[prefix[$:/temp/]] -[prefix[$:/HistoryList]]` - save all tiddlers except popup state tiddlers, temp tiddlers and the history list.
|
||||||
|
|
||||||
<$link to="$:/config/BrowserStorage/SaveFilter">Browser Storage Save Filter</$link>: <$edit-text tiddler="$:/config/BrowserStorage/SaveFilter" default="" tag="input" size="50"/>
|
<$link to="$:/config/BrowserStorage/SaveFilter">Browser Storage Save Filter</$link>: <$edit-text tiddler="$:/config/BrowserStorage/SaveFilter" default="" tag="input" size="50"/>
|
||||||
|
|
||||||
|
@ -53,6 +53,8 @@ BrowserStorageUtil.prototype.saveTiddlerToLocalStorage = function(title) {
|
|||||||
// Get the tiddler
|
// Get the tiddler
|
||||||
var tiddler = $tw.wiki.getTiddler(title);
|
var tiddler = $tw.wiki.getTiddler(title);
|
||||||
if(tiddler) {
|
if(tiddler) {
|
||||||
|
if (this.wiki.tiddlerExists(title)) {
|
||||||
|
// This is not a shadow tiddler
|
||||||
console.log("browser-storage: Saving",title);
|
console.log("browser-storage: Saving",title);
|
||||||
// Get the JSON of the tiddler
|
// Get the JSON of the tiddler
|
||||||
var json = JSON.stringify(tiddler.getFieldStrings());
|
var json = JSON.stringify(tiddler.getFieldStrings());
|
||||||
@ -72,6 +74,11 @@ BrowserStorageUtil.prototype.saveTiddlerToLocalStorage = function(title) {
|
|||||||
console.log("Browser-storage error:",e);
|
console.log("Browser-storage error:",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Shadow tiddler which is no longer overwritten (or never was)
|
||||||
|
// Ensure it is not in local storage
|
||||||
|
this.removeTiddlerFromLocalStorage(title);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// In local storage, use the special value of empty string to mark the tiddler as deleted
|
// In local storage, use the special value of empty string to mark the tiddler as deleted
|
||||||
// On future page loads, if the tiddler is already gone from startup then the blank entry
|
// On future page loads, if the tiddler is already gone from startup then the blank entry
|
||||||
|
Loading…
Reference in New Issue
Block a user