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);
|
||||
|
||||
store.loaded.then(async () => {
|
||||
misskeyApi('i/registry/get', { scope: ['client'], key: 'themes' }).catch(() => []).then((themes: Theme[]) => {
|
||||
if (themes.length > 0) {
|
||||
prefer.commit('themes', themes);
|
||||
prefer.suppressReload();
|
||||
|
||||
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);
|
||||
misskeyApi('i/registry/keys', {
|
||||
await misskeyApi('i/registry/keys', {
|
||||
scope: ['client', 'deck', 'profiles'],
|
||||
}).then(async keys => {
|
||||
const profiles: DeckProfile[] = [];
|
||||
|
@ -42,16 +44,18 @@ export function migrateOldSettings() {
|
|||
const deck = await misskeyApi('i/registry/get', {
|
||||
scope: ['client', 'deck', 'profiles'],
|
||||
key: key,
|
||||
});
|
||||
profiles.push({
|
||||
id: uuid(),
|
||||
name: key,
|
||||
columns: deck.columns,
|
||||
layout: deck.layout,
|
||||
});
|
||||
}).catch(() => null);
|
||||
if (deck) {
|
||||
profiles.push({
|
||||
id: uuid(),
|
||||
name: key,
|
||||
columns: (deck as DeckProfile).columns,
|
||||
layout: (deck as DeckProfile).layout,
|
||||
});
|
||||
}
|
||||
}
|
||||
prefer.commit('deck.profiles', profiles);
|
||||
});
|
||||
}).catch(() => null);
|
||||
|
||||
prefer.commit('lightTheme', ColdDeviceStorage.get('lightTheme'));
|
||||
prefer.commit('darkTheme', ColdDeviceStorage.get('darkTheme'));
|
||||
|
@ -165,9 +169,6 @@ export function migrateOldSettings() {
|
|||
prefer.commit('warnMissingAltText', store.s.warnMissingAltText);
|
||||
//#endregion
|
||||
|
||||
window.setTimeout(() => {
|
||||
unisonReload();
|
||||
}, 10000);
|
||||
//#region Hybrid migrations
|
||||
prefer.commit('fontSize', miLocalStorage.getItem('fontSize') ?? '0');
|
||||
prefer.commit('useSystemFont', miLocalStorage.getItem('useSystemFont') != null);
|
||||
|
@ -178,5 +179,7 @@ export function migrateOldSettings() {
|
|||
prefer.commit('neverShowLocalOnlyInfo', miLocalStorage.getItem('neverShowLocalOnlyInfo') != null);
|
||||
//#endregion
|
||||
|
||||
prefer.allowReload();
|
||||
unisonReload();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue