Skip to content

Commit 18b52a9

Browse files
committed
Use timeout to wait for further before saving customFilter
So as to avoid overloading chrome.storage.sync
1 parent 7567e96 commit 18b52a9

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

extension/options/js/options.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
var alertTimeout;
22

3+
var customFilterTimeout;
4+
35
function showSavedAlert() {
46
clearTimeout(alertTimeout);
57
$(".alert").addClass("show");
@@ -69,11 +71,14 @@ function setListeners() {
6971
});
7072
});
7173
$("#custom_filter").on("input", function() {
72-
chrome.storage.sync.set({
73-
customFilter: this.value
74-
}, function() {
75-
showSavedAlert();
76-
});
74+
clearTimeout(customFilterTimeout);
75+
customFilterTimeout = setTimeout(function() {
76+
chrome.storage.sync.set({
77+
customFilter: this.value
78+
}, function() {
79+
showSavedAlert();
80+
});
81+
}, 250);
7782
});
7883
}
7984

0 commit comments

Comments
 (0)