mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 12:36:57 +00:00
fix race conditions and bugs in pref-migrate.ts
This commit is contained in:
parent
4085c8a4f1
commit
e3668be8f4
1 changed files with 18 additions and 15 deletions
|
@ -20,9 +20,11 @@ export function migrateOldSettings() {
|
||||||
os.waiting(i18n.ts.settingsMigrating);
|
os.waiting(i18n.ts.settingsMigrating);
|
||||||
|
|
||||||
store.loaded.then(async () => {
|
store.loaded.then(async () => {
|
||||||
misskeyApi('i/registry/get', { scope: ['client'], key: 'themes' }).catch(() => []).then((themes: Theme[]) => {
|
prefer.suppressReload();
|
||||||
if (themes.length > 0) {
|
|
||||||
prefer.commit('themes', themes);
|
await misskeyApi('i/registry/get', { scope: ['client'], key: 'themes' }).catch(() => []).then(themes => {
|
||||||
|
if (Array.isArray(themes) && themes.length > 0) {
|
||||||
|
prefer.commit('themes', themes as Theme[]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -34,7 +36,7 @@ export function migrateOldSettings() {
|
||||||
})));
|
})));
|
||||||
|
|
||||||
prefer.commit('deck.profile', deckStore.s.profile);
|
prefer.commit('deck.profile', deckStore.s.profile);
|
||||||
misskeyApi('i/registry/keys', {
|
await misskeyApi('i/registry/keys', {
|
||||||
scope: ['client', 'deck', 'profiles'],
|
scope: ['client', 'deck', 'profiles'],
|
||||||
}).then(async keys => {
|
}).then(async keys => {
|
||||||
const profiles: DeckProfile[] = [];
|
const profiles: DeckProfile[] = [];
|
||||||
|
@ -42,16 +44,18 @@ export function migrateOldSettings() {
|
||||||
const deck = await misskeyApi('i/registry/get', {
|
const deck = await misskeyApi('i/registry/get', {
|
||||||
scope: ['client', 'deck', 'profiles'],
|
scope: ['client', 'deck', 'profiles'],
|
||||||
key: key,
|
key: key,
|
||||||
});
|
}).catch(() => null);
|
||||||
profiles.push({
|
if (deck) {
|
||||||
id: uuid(),
|
profiles.push({
|
||||||
name: key,
|
id: uuid(),
|
||||||
columns: deck.columns,
|
name: key,
|
||||||
layout: deck.layout,
|
columns: (deck as DeckProfile).columns,
|
||||||
});
|
layout: (deck as DeckProfile).layout,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
prefer.commit('deck.profiles', profiles);
|
prefer.commit('deck.profiles', profiles);
|
||||||
});
|
}).catch(() => null);
|
||||||
|
|
||||||
prefer.commit('lightTheme', ColdDeviceStorage.get('lightTheme'));
|
prefer.commit('lightTheme', ColdDeviceStorage.get('lightTheme'));
|
||||||
prefer.commit('darkTheme', ColdDeviceStorage.get('darkTheme'));
|
prefer.commit('darkTheme', ColdDeviceStorage.get('darkTheme'));
|
||||||
|
@ -165,9 +169,6 @@ export function migrateOldSettings() {
|
||||||
prefer.commit('warnMissingAltText', store.s.warnMissingAltText);
|
prefer.commit('warnMissingAltText', store.s.warnMissingAltText);
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
window.setTimeout(() => {
|
|
||||||
unisonReload();
|
|
||||||
}, 10000);
|
|
||||||
//#region Hybrid migrations
|
//#region Hybrid migrations
|
||||||
prefer.commit('fontSize', miLocalStorage.getItem('fontSize') ?? '0');
|
prefer.commit('fontSize', miLocalStorage.getItem('fontSize') ?? '0');
|
||||||
prefer.commit('useSystemFont', miLocalStorage.getItem('useSystemFont') != null);
|
prefer.commit('useSystemFont', miLocalStorage.getItem('useSystemFont') != null);
|
||||||
|
@ -178,5 +179,7 @@ export function migrateOldSettings() {
|
||||||
prefer.commit('neverShowLocalOnlyInfo', miLocalStorage.getItem('neverShowLocalOnlyInfo') != null);
|
prefer.commit('neverShowLocalOnlyInfo', miLocalStorage.getItem('neverShowLocalOnlyInfo') != null);
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
prefer.allowReload();
|
||||||
|
unisonReload();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue