[Storage > Parity] Rewrite with clear function to fix resetting

pull/55/head
Oj18 3 years ago
parent 5c89883115
commit b9fe8dfea3

@ -1,5 +1,18 @@
# GooseMod Changelog
## v12.2-dev [2021-10-22]
- ### Canary Fixes
- **Fixed various things for new Canary update.** Discord rolled out a new Canary update on the 22nd of October which changed many internal things. All mods broke including GooseMod was broken but now most things should be working fine. You may have some minor issues with GooseMod or issues with some plugins, if so feel free to report in our Discord.
- ### General Hotfixes
- **Fixed GM reset option.**
- **Fixed Guild badges.**
- **Fixed Snippets (experimental option).**
- **Fixed modules sometimes failing to load.**
- **Updated translations.**
## v12.1 [2021-09-18]
- ### Store

@ -108,7 +108,7 @@ const init = async function () {
}
this.versioning = {
version: `12.1`,
version: `12.2-dev`,
hash: '<hash>', // Hash of built final js file is inserted here via build script
lastUsedVersion: this.storage.get('goosemodLastVersion')
@ -205,7 +205,7 @@ const init = async function () {
clearInterval(this.saveInterval);
clearInterval(this.hotupdateInterval);
this.storage.keys().filter((x) => x.toLowerCase().startsWith('goosemod')).forEach((x) => this.storage.remove(x));
this.storage.clear();
this.removed = true;

@ -55,4 +55,10 @@ export const remove = (key) => {
backup();
};
export const clear = () => {
keys().filter((x) => x.toLowerCase().startsWith('goosemod')).forEach((y) => remove(x)); // Extension
for (const system of paritySystems) await system.clear();
};
export const keys = () => Object.keys(storageCache);

@ -9,4 +9,11 @@ export const restore = async ({ set }) => { // Extension migration should do thi
if (!window.localStorage) return;
Object.keys(localStorage).filter((x) => x.toLowerCase().startsWith('goosemod')).forEach((x) => set(x, localStorage.getItem(x)));
};
export const clear = async () => {
if (!window.localStorage) return;
Object.keys(localStorage).filter((x) => x.toLowerCase().startsWith('goosemod')).forEach((y) => localStorage.removeItem(y));
};

@ -17,3 +17,17 @@ export const restore = async ({ set }) => {
Object.keys(cache).filter((x) => x.toLowerCase().startsWith('goosemod')).forEach((x) => set(x, cache[x]));
};
export const clear = async () => {
if (!window.DiscordNative?.userDataCache) return;
const cache = await DiscordNative.userDataCache.getCached();
if (!cache) return; // No userDataCache
Object.keys(cache).filter((x) => x.toLowerCase().startsWith('goosemod')).forEach((y) => {
delete cache[y];
DiscordNative.userDataCache.cacheUserData(JSON.stringify(cache));
});
};
Loading…
Cancel
Save