diff --git a/plugins/tiddlywiki/browser-storage/settings.tid b/plugins/tiddlywiki/browser-storage/settings.tid index 6379d15fe..3ecf54d7c 100644 --- a/plugins/tiddlywiki/browser-storage/settings.tid +++ b/plugins/tiddlywiki/browser-storage/settings.tid @@ -4,3 +4,6 @@ This filter determines which tiddlers will be saved to local storage. By default <$link to="$:/config/BrowserStorage/SaveFilter">Browser Storage Save Filter: <$edit-text tiddler="$:/config/BrowserStorage/SaveFilter" default="" tag="input" size="50"/> +This setting allows a custom alert message to be displayed when an attempt to store a tiddler fails due to the storage quota being exceeded: + +<$link to="$:/config/BrowserStorage/QuotaExceededAlert">Quota Exceeded Alert: <$edit-text tiddler="$:/config/BrowserStorage/QuotaExceededAlert" default="" tag="input" size="50"/> diff --git a/plugins/tiddlywiki/browser-storage/startup.js b/plugins/tiddlywiki/browser-storage/startup.js index 6589b1757..77b7fd2f1 100644 --- a/plugins/tiddlywiki/browser-storage/startup.js +++ b/plugins/tiddlywiki/browser-storage/startup.js @@ -18,7 +18,10 @@ exports.platforms = ["browser"]; exports.after = ["load-modules"]; exports.synchronous = true; -var SAVE_FILTER_TITLE = "$:/config/BrowserStorage/SaveFilter" +var SAVE_FILTER_TITLE = "$:/config/BrowserStorage/SaveFilter", + QUOTA_EXCEEDED_ALERT_TITLE = "$:/config/BrowserStorage/QuotaExceededAlert", + DEFAULT_QUOTA_EXCEEDED_ALERT_PREFIX = "Quota exceeded attempting to store `", + DEFAULT_QUOTA_EXCEEDED_ALERT_SUFFIX = "` in browser local storage"; exports.startup = function() { var self = this; @@ -61,7 +64,8 @@ console.log("Filtered changes",filteredChanges) } catch(e) { if(e.name === "QuotaExceededError") { // Complain if we failed - logger.alert("Quota exceeded trying to store '" + title + "' in browser local storage"); + var msg = $tw.wiki.getTiddlerText(QUOTA_EXCEEDED_ALERT_TITLE,DEFAULT_QUOTA_EXCEEDED_ALERT_PREFIX + title + DEFAULT_QUOTA_EXCEEDED_ALERT_SUFFIX); + logger.alert(msg); // No point in keeping old values around for this tiddler window.localStorage.removeItem(prefix + title); } else {