fix #2370
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
(function() {
|
(function() {
|
||||||
Danbooru.Autocomplete = {};
|
Danbooru.Autocomplete = {};
|
||||||
|
|
||||||
|
Danbooru.Autocomplete.AUTOCOMPLETE_VERSION = 1;
|
||||||
|
|
||||||
Danbooru.Autocomplete.initialize_all = function() {
|
Danbooru.Autocomplete.initialize_all = function() {
|
||||||
if (Danbooru.meta("enable-auto-complete") === "true") {
|
if (Danbooru.meta("enable-auto-complete") === "true") {
|
||||||
Danbooru.Autocomplete.enable_local_storage = this.test_local_storage();
|
Danbooru.Autocomplete.enable_local_storage = this.test_local_storage();
|
||||||
@@ -21,8 +23,14 @@
|
|||||||
|
|
||||||
Danbooru.Autocomplete.prune_local_storage = function() {
|
Danbooru.Autocomplete.prune_local_storage = function() {
|
||||||
if (this.enable_local_storage) {
|
if (this.enable_local_storage) {
|
||||||
if ($.localStorage.keys().length > 4000) {
|
var cached_autocomplete_version = $.localStorage.get("danbooru-autocomplete-version");
|
||||||
$.localStorage.removeAll();
|
if (cached_autocomplete_version !== this.AUTOCOMPLETE_VERSION || $.localStorage.keys().length > 4000) {
|
||||||
|
$.each($.localStorage.keys(), function(i, key) {
|
||||||
|
if (key.substr(0, 3) === "ac-") {
|
||||||
|
$.localStorage.remove(key);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$.localStorage.set("danbooru-autocomplete-version", this.AUTOCOMPLETE_VERSION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -167,8 +175,12 @@
|
|||||||
if (this.enable_local_storage) {
|
if (this.enable_local_storage) {
|
||||||
var cached = $.localStorage.get(key);
|
var cached = $.localStorage.get(key);
|
||||||
if (cached) {
|
if (cached) {
|
||||||
resp(cached.value);
|
if (Date.parse(cached.expires) < new Date().getTime()) {
|
||||||
return;
|
$.localStorage.remove(key);
|
||||||
|
} else {
|
||||||
|
resp(cached.value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user