Skip to content

Commit 199bab7

Browse files
committed
clear storage automatically if quota exceeded
1 parent cc16d28 commit 199bab7

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/storage.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ window.setSyncStorage = promisify(chrome.storage.sync.set.bind(chrome.storage.sy
2929
window.setStorage = (CONTRIBUTOR, ORG_REPO_PATH, value) => {
3030
return window.setSyncStorage({
3131
[`${CONTRIBUTOR}|${ORG_REPO_PATH}`]: value
32+
})
33+
.catch((e) => {
34+
if (e.message === "MAX_ITEMS quota exceeded") {
35+
getSyncStorage({ "access_token": null })
36+
.then(({ access_token }) => {
37+
if (access_token) {
38+
chrome.storage.sync.clear(() => {
39+
setSyncStorage({ "access_token": access_token });
40+
});
41+
}
42+
});
43+
}
3244
});
3345
};
3446

0 commit comments

Comments
 (0)