enhance(frontend): improve migration of old settings

This commit is contained in:
syuilo 2025-04-07 10:21:49 +09:00
parent 1ede45c8fb
commit 6ef5c8bb92
6 changed files with 18 additions and 8 deletions

4
locales/index.d.ts vendored
View File

@ -5382,6 +5382,10 @@ export interface Locale extends ILocale {
* *
*/ */
"embed": string; "embed": string;
/**
* ... ( )
*/
"settingsMigrating": string;
"_chat": { "_chat": {
/** /**
* *

View File

@ -1341,6 +1341,7 @@ right: "右"
bottom: "下" bottom: "下"
top: "上" top: "上"
embed: "埋め込み" embed: "埋め込み"
settingsMigrating: "設定を移行しています。しばらくお待ちください... (後ほど、設定→その他→旧設定情報を移行 で手動で移行することもできます)"
_chat: _chat:
noMessagesYet: "まだメッセージはありません" noMessagesYet: "まだメッセージはありません"

View File

@ -22,7 +22,7 @@ const modal = useTemplateRef('modal');
const props = defineProps<{ const props = defineProps<{
success: boolean; success: boolean;
showing: boolean; showing: boolean;
text?: string; text?: string | null;
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{

View File

@ -547,12 +547,13 @@ export function success(): Promise<void> {
}); });
} }
export function waiting(): Promise<void> { export function waiting(text?: string | null): Promise<void> {
return new Promise(resolve => { return new Promise(resolve => {
const showing = ref(true); const showing = ref(true);
const { dispose } = popup(MkWaitingDialog, { const { dispose } = popup(MkWaitingDialog, {
success: false, success: false,
showing: showing, showing: showing,
text,
}, { }, {
done: () => resolve(), done: () => resolve(),
closed: () => dispose(), closed: () => dispose(),

View File

@ -185,7 +185,6 @@ async function deleteAccount() {
} }
function migrate() { function migrate() {
os.waiting();
migrateOldSettings(); migrateOldSettings();
} }

View File

@ -10,14 +10,19 @@ import { prefer } from '@/preferences.js';
import { misskeyApi } from '@/utility/misskey-api.js'; import { misskeyApi } from '@/utility/misskey-api.js';
import { deckStore } from '@/ui/deck/deck-store.js'; import { deckStore } from '@/ui/deck/deck-store.js';
import { unisonReload } from '@/utility/unison-reload.js'; import { unisonReload } from '@/utility/unison-reload.js';
import * as os from '@/os.js';
import { i18n } from '@/i18n.js';
// TODO: そのうち消す // TODO: そのうち消す
export function migrateOldSettings() { export function migrateOldSettings() {
os.waiting(i18n.ts.settingsMigrating);
store.loaded.then(async () => { store.loaded.then(async () => {
const themes = await misskeyApi('i/registry/get', { scope: ['client'], key: 'themes' }).catch(() => []); misskeyApi('i/registry/get', { scope: ['client'], key: 'themes' }).catch(() => []).then((themes: any) => {
if (themes.length > 0) { if (themes.length > 0) {
prefer.commit('themes', themes); prefer.commit('themes', themes);
} }
});
const plugins = ColdDeviceStorage.get('plugins'); const plugins = ColdDeviceStorage.get('plugins');
prefer.commit('plugins', plugins.map(p => ({ prefer.commit('plugins', plugins.map(p => ({
@ -136,6 +141,6 @@ export function migrateOldSettings() {
window.setTimeout(() => { window.setTimeout(() => {
unisonReload(); unisonReload();
}, 5000); }, 10000);
}); });
} }