summaryrefslogtreecommitdiff
path: root/packages/frontend/src/ui/deck/deck-store.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/frontend/src/ui/deck/deck-store.ts')
-rw-r--r--packages/frontend/src/ui/deck/deck-store.ts14
1 files changed, 10 insertions, 4 deletions
diff --git a/packages/frontend/src/ui/deck/deck-store.ts b/packages/frontend/src/ui/deck/deck-store.ts
index 002d409f78..9055ea6d43 100644
--- a/packages/frontend/src/ui/deck/deck-store.ts
+++ b/packages/frontend/src/ui/deck/deck-store.ts
@@ -51,7 +51,7 @@ export type Column = {
withReplies?: boolean;
withSensitive?: boolean;
onlyFiles?: boolean;
- soundSetting: SoundStore;
+ soundSetting?: SoundStore;
};
export const deckStore = markRaw(new Storage('deck', {
@@ -94,7 +94,7 @@ export const loadDeck = async () => {
key: deckStore.state.profile,
});
} catch (err) {
- if (err.code === 'NO_SUCH_KEY') {
+ if (typeof err === 'object' && err != null && 'code' in err && err.code === 'NO_SUCH_KEY') {
// 後方互換性のため
if (deckStore.state.profile === 'default') {
saveDeck();
@@ -180,6 +180,7 @@ export function swapLeftColumn(id: Column['id']) {
}
return true;
}
+ return false;
});
saveDeck();
}
@@ -196,6 +197,7 @@ export function swapRightColumn(id: Column['id']) {
}
return true;
}
+ return false;
});
saveDeck();
}
@@ -216,6 +218,7 @@ export function swapUpColumn(id: Column['id']) {
}
return true;
}
+ return false;
});
saveDeck();
}
@@ -236,6 +239,7 @@ export function swapDownColumn(id: Column['id']) {
}
return true;
}
+ return false;
});
saveDeck();
}
@@ -286,7 +290,8 @@ export function removeColumnWidget(id: Column['id'], widget: ColumnWidget) {
const columns = deepClone(deckStore.state.columns);
const columnIndex = deckStore.state.columns.findIndex(c => c.id === id);
const column = deepClone(deckStore.state.columns[columnIndex]);
- if (column == null || column.widgets == null) return;
+ if (column == null) return;
+ if (column.widgets == null) column.widgets = [];
column.widgets = column.widgets.filter(w => w.id !== widget.id);
columns[columnIndex] = column;
deckStore.set('columns', columns);
@@ -308,7 +313,8 @@ export function updateColumnWidget(id: Column['id'], widgetId: string, widgetDat
const columns = deepClone(deckStore.state.columns);
const columnIndex = deckStore.state.columns.findIndex(c => c.id === id);
const column = deepClone(deckStore.state.columns[columnIndex]);
- if (column == null || column.widgets == null) return;
+ if (column == null) return;
+ if (column.widgets == null) column.widgets = [];
column.widgets = column.widgets.map(w => w.id === widgetId ? {
...w,
data: widgetData,