Delete items if exceeding storage

This commit is contained in:
Ajay
2022-05-31 13:31:18 -04:00
parent d7ff6aa6a2
commit 67c63a09fe

View File

@@ -370,8 +370,20 @@ function configProxy(): { sync: SBConfig, local: SBStorage } {
} }
function forceSyncUpdate(prop: string): void { function forceSyncUpdate(prop: string): void {
const value = Config.cachedSyncConfig[prop];
if (prop === "unsubmittedSegments") {
// Early to be safe
if (JSON.stringify(value).length + prop.length > 8000) {
for (const key in value) {
if (!value[key] || value[key].length <= 0) {
delete value[key];
}
}
}
}
chrome.storage.sync.set({ chrome.storage.sync.set({
[prop]: Config.cachedSyncConfig[prop] [prop]: value
}); });
} }