allow deck column updates to be awaited
This commit is contained in:
parent
a40b77a66b
commit
455ccc660e
|
@ -112,8 +112,8 @@ export const loadDeck = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: deckがloadされていない状態でsaveすると意図せず上書きが発生するので対策する
|
// TODO: deckがloadされていない状態でsaveすると意図せず上書きが発生するので対策する
|
||||||
export const saveDeck = throttle(1000, () => {
|
export const saveDeck = throttle(1000, async () => {
|
||||||
misskeyApi('i/registry/set', {
|
await misskeyApi('i/registry/set', {
|
||||||
scope: ['client', 'deck', 'profiles'],
|
scope: ['client', 'deck', 'profiles'],
|
||||||
key: deckStore.state.profile,
|
key: deckStore.state.profile,
|
||||||
value: {
|
value: {
|
||||||
|
@ -313,7 +313,7 @@ export function updateColumnWidget(id: Column['id'], widgetId: string, widgetDat
|
||||||
saveDeck();
|
saveDeck();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateColumn(id: Column['id'], column: Partial<Column>) {
|
export async function updateColumn<TColumn>(id: Column['id'], column: Partial<TColumn>) {
|
||||||
const columns = deepClone(deckStore.state.columns);
|
const columns = deepClone(deckStore.state.columns);
|
||||||
const columnIndex = deckStore.state.columns.findIndex(c => c.id === id);
|
const columnIndex = deckStore.state.columns.findIndex(c => c.id === id);
|
||||||
const currentColumn = deepClone(deckStore.state.columns[columnIndex]);
|
const currentColumn = deepClone(deckStore.state.columns[columnIndex]);
|
||||||
|
@ -322,6 +322,8 @@ export function updateColumn(id: Column['id'], column: Partial<Column>) {
|
||||||
currentColumn[k] = v;
|
currentColumn[k] = v;
|
||||||
}
|
}
|
||||||
columns[columnIndex] = currentColumn;
|
columns[columnIndex] = currentColumn;
|
||||||
deckStore.set('columns', columns);
|
await Promise.all([
|
||||||
saveDeck();
|
deckStore.set('columns', columns),
|
||||||
|
saveDeck(),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue