diff --git a/packages/frontend/src/os.ts b/packages/frontend/src/os.ts index f656a52371..3fca924c05 100644 --- a/packages/frontend/src/os.ts +++ b/packages/frontend/src/os.ts @@ -294,6 +294,21 @@ export function inputText(props: { } | { canceled: false; result: string; }>; +// min lengthが指定されてたら result は null になり得ないことを保証する overload function +export function inputText(props: { + type?: 'text' | 'email' | 'password' | 'url'; + title?: string; + text?: string; + placeholder?: string | null; + autocomplete?: string; + default?: string; + minLength: number; + maxLength?: number; +}): Promise<{ + canceled: true; result: undefined; +} | { + canceled: false; result: string; +}>; export function inputText(props: { type?: 'text' | 'email' | 'password' | 'url'; title?: string; diff --git a/packages/frontend/src/ui/deck.vue b/packages/frontend/src/ui/deck.vue index bdb62dca15..1356bbb073 100644 --- a/packages/frontend/src/ui/deck.vue +++ b/packages/frontend/src/ui/deck.vue @@ -24,7 +24,7 @@ SPDX-License-Identifier: AGPL-3.0-only :ref="id" :key="id" :class="$style.column" - :column="columns.find(c => c.id === id)" + :column="columns.find(c => c.id === id)!" :isStacked="ids.length > 1" @headerWheel="onWheel" /> @@ -185,7 +185,7 @@ const addColumn = async (ev) => { 'mentions', 'direct', 'roleTimeline', - ]; + ] as const; const { canceled, result: column } = await os.select({ title: i18n.ts._deck.addColumn, @@ -194,6 +194,7 @@ const addColumn = async (ev) => { })), }); if (canceled) return; + if (column == null) return; addColumnToStore({ type: column, @@ -212,7 +213,7 @@ const onContextmenu = (ev) => { function onWheel(ev: WheelEvent) { if (ev.deltaX === 0) { - columnsEl.value.scrollLeft += ev.deltaY; + columnsEl.value!.scrollLeft += ev.deltaY; } } diff --git a/packages/frontend/src/ui/deck/deck-store.ts b/packages/frontend/src/ui/deck/deck-store.ts index bb3c04cd5c..e6fe6eedde 100644 --- a/packages/frontend/src/ui/deck/deck-store.ts +++ b/packages/frontend/src/ui/deck/deck-store.ts @@ -19,7 +19,7 @@ type ColumnWidget = { export type Column = { id: string; - type: 'main' | 'widgets' | 'notifications' | 'tl' | 'antenna' | 'channel' | 'list' | 'mentions' | 'direct'; + type: 'main' | 'widgets' | 'notifications' | 'tl' | 'antenna' | 'channel' | 'list' | 'mentions' | 'direct' | 'roleTimeline'; name: string | null; width: number; widgets?: ColumnWidget[]; @@ -34,7 +34,7 @@ export type Column = { withRenotes?: boolean; withReplies?: boolean; onlyFiles?: boolean; - soundSetting: SoundStore; + soundSetting?: SoundStore; }; export const deckStore = markRaw(new Storage('deck', { @@ -77,7 +77,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(); @@ -159,6 +159,7 @@ export function swapLeftColumn(id: Column['id']) { } return true; } + return false; }); saveDeck(); } @@ -175,6 +176,7 @@ export function swapRightColumn(id: Column['id']) { } return true; } + return false; }); saveDeck(); } @@ -195,6 +197,7 @@ export function swapUpColumn(id: Column['id']) { } return true; } + return false; }); saveDeck(); } @@ -215,6 +218,7 @@ export function swapDownColumn(id: Column['id']) { } return true; } + return false; }); saveDeck(); } @@ -266,6 +270,7 @@ export function removeColumnWidget(id: Column['id'], widget: ColumnWidget) { const columnIndex = deckStore.state.columns.findIndex(c => c.id === id); const column = deepClone(deckStore.state.columns[columnIndex]); 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); @@ -288,6 +293,7 @@ export function updateColumnWidget(id: Column['id'], widgetId: string, widgetDat const columnIndex = deckStore.state.columns.findIndex(c => c.id === id); const column = deepClone(deckStore.state.columns[columnIndex]); if (column == null) return; + if (column.widgets == null) column.widgets = []; column.widgets = column.widgets.map(w => w.id === widgetId ? { ...w, data: widgetData,