mirror of https://github.com/GooseMod/GooseMod
[Storage > Ext] Hybrid 2 (rewrite)
parent
c918f67dbf
commit
c38dd3bd1f
@ -0,0 +1,12 @@
|
||||
export const backup = async ({ keys, get }) => {
|
||||
if (!window.localStorage) return;
|
||||
|
||||
for (const k of keys()) localStorage.setItem(k, get(k));
|
||||
};
|
||||
|
||||
|
||||
export const restore = async ({ set }) => { // Extension migration should do this automatically, but try anyway?
|
||||
if (!window.localStorage) return;
|
||||
|
||||
Object.keys(localStorage).filter((x) => x.toLowerCase().startsWith('goosemod')).forEach((x) => set(x, localStorage.getItem(x)));
|
||||
};
|
@ -0,0 +1,18 @@
|
||||
export const backup = async ({ keys, get }) => {
|
||||
if (!window.DiscordNative?.userDataCache) return;
|
||||
|
||||
const cache = await DiscordNative.userDataCache.getCached();
|
||||
|
||||
for (const k of keys()) cache[k] = get(k);
|
||||
|
||||
DiscordNative.userDataCache.cacheUserData(JSON.stringify(cache));
|
||||
};
|
||||
|
||||
|
||||
export const restore = async ({ set }) => {
|
||||
if (!window.DiscordNative?.userDataCache) return;
|
||||
|
||||
const cache = await DiscordNative.userDataCache.getCached();
|
||||
|
||||
Object.keys(cache).filter((x) => x.toLowerCase().startsWith('goosemod')).forEach((x) => set(x, cache[x]));
|
||||
};
|
Loading…
Reference in new issue