Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): デッキのプロファイルが新規作成できない問題を修正 #15406

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Fix: データセーバー有効時にもユーザーページの「ファイル」タブで画像が読み込まれてしまう問題を修正
- Fix: MFMの `sparkle` エフェクトが正しく表示されない問題を修正
- Fix: ページのURLにスラッシュが含まれている場合にページが正しく表示されない問題を修正
- Fix: デッキのプロファイルが新規作成できない問題を修正
- ローカライゼーションの更新
- Playが実装されたため、ページ機能の「ソースを見る」は削除されました

Expand Down
26 changes: 20 additions & 6 deletions packages/frontend/src/ui/deck.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { computed, defineAsyncComponent, ref, watch, shallowRef } from 'vue';
import { v4 as uuid } from 'uuid';
import XCommon from './_common_/common.vue';
import { deckStore, columnTypes, addColumn as addColumnToStore, loadDeck, getProfiles, deleteProfile as deleteProfile_ } from './deck/deck-store.js';
import { deckStore, columnTypes, addColumn as addColumnToStore, forceSaveDeck, loadDeck, getProfiles, deleteProfile as deleteProfile_ } from './deck/deck-store.js';
import type { ColumnType } from './deck/deck-store.js';
import type { MenuItem } from '@/types/menu.js';
import XSidebar from '@/ui/_common_/navbar.vue';
Expand Down Expand Up @@ -233,10 +233,15 @@ function changeProfile(ev: MouseEvent) {
title: i18n.ts._deck.profile,
minLength: 1,
});

if (canceled || name == null) return;

deckStore.set('profile', name);
unisonReload();
os.promiseDialog((async () => {
await deckStore.set('profile', name);
await forceSaveDeck();
})(), () => {
unisonReload();
});
},
});
}).then(() => {
Expand All @@ -251,9 +256,18 @@ async function deleteProfile() {
});
if (canceled) return;

deleteProfile_(deckStore.state.profile);
deckStore.set('profile', 'default');
unisonReload();
os.promiseDialog((async () => {
if (deckStore.state.profile === 'default') {
await deckStore.set('columns', []);
await deckStore.set('layout', []);
await forceSaveDeck();
} else {
await deleteProfile_(deckStore.state.profile);
}
await deckStore.set('profile', 'default');
})(), () => {
unisonReload();
});
}
</script>

Expand Down
10 changes: 7 additions & 3 deletions packages/frontend/src/ui/deck/deck-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,20 @@ export const loadDeck = async () => {
deckStore.set('layout', deck.layout);
};

// TODO: deckがloadされていない状態でsaveすると意図せず上書きが発生するので対策する
export const saveDeck = throttle(1000, () => {
misskeyApi('i/registry/set', {
export async function forceSaveDeck() {
await misskeyApi('i/registry/set', {
scope: ['client', 'deck', 'profiles'],
key: deckStore.state.profile,
value: {
columns: deckStore.reactiveState.columns.value,
layout: deckStore.reactiveState.layout.value,
},
});
}

// TODO: deckがloadされていない状態でsaveすると意図せず上書きが発生するので対策する
export const saveDeck = throttle(1000, () => {
forceSaveDeck();
});

export async function getProfiles(): Promise<string[]> {
Expand Down
Loading