mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
BrowserStorage: Add support for a custom quota exceeded message
This commit is contained in:
parent
51b4f63c5c
commit
5577f7a4fe
@ -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</$link>: <$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</$link>: <$edit-text tiddler="$:/config/BrowserStorage/QuotaExceededAlert" default="" tag="input" size="50"/>
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user