From 045c9bf0881bcc11be6925778668fb2f176221ea Mon Sep 17 00:00:00 2001 From: Michcio Date: Tue, 26 Jul 2022 18:06:19 +0200 Subject: [PATCH] Remove Deck UI I'm not sure this even makes sense, I was just trying to remove more code from the client. --- packages/client/src/init.ts | 1 - packages/client/src/menu.ts | 7 - packages/client/src/os.ts | 2 - packages/client/src/pages/settings/deck.vue | 73 ---- .../client/src/pages/settings/general.vue | 2 - packages/client/src/pages/settings/index.vue | 1 - packages/client/src/ui/deck.vue | 289 -------------- .../client/src/ui/deck/antenna-column.vue | 63 --- packages/client/src/ui/deck/column-core.vue | 43 -- packages/client/src/ui/deck/column.vue | 377 ------------------ packages/client/src/ui/deck/deck-store.ts | 304 -------------- packages/client/src/ui/deck/direct-column.vue | 30 -- packages/client/src/ui/deck/list-column.vue | 65 --- packages/client/src/ui/deck/main-column.vue | 44 -- .../client/src/ui/deck/mentions-column.vue | 27 -- .../src/ui/deck/notifications-column.vue | 38 -- packages/client/src/ui/deck/tl-column.vue | 129 ------ .../client/src/ui/deck/widgets-column.vue | 56 --- 18 files changed, 1551 deletions(-) delete mode 100644 packages/client/src/pages/settings/deck.vue delete mode 100644 packages/client/src/ui/deck.vue delete mode 100644 packages/client/src/ui/deck/antenna-column.vue delete mode 100644 packages/client/src/ui/deck/column-core.vue delete mode 100644 packages/client/src/ui/deck/column.vue delete mode 100644 packages/client/src/ui/deck/deck-store.ts delete mode 100644 packages/client/src/ui/deck/direct-column.vue delete mode 100644 packages/client/src/ui/deck/list-column.vue delete mode 100644 packages/client/src/ui/deck/main-column.vue delete mode 100644 packages/client/src/ui/deck/mentions-column.vue delete mode 100644 packages/client/src/ui/deck/notifications-column.vue delete mode 100644 packages/client/src/ui/deck/tl-column.vue delete mode 100644 packages/client/src/ui/deck/widgets-column.vue diff --git a/packages/client/src/init.ts b/packages/client/src/init.ts index d428c9ceb..386eb9393 100644 --- a/packages/client/src/init.ts +++ b/packages/client/src/init.ts @@ -171,7 +171,6 @@ import { getAccountFromId } from '@/scripts/get-account-from-id'; const app = createApp( window.location.search === '?zen' ? defineAsyncComponent(() => import('@/ui/zen.vue')) : !$i ? defineAsyncComponent(() => import('@/ui/visitor.vue')) : - ui === 'deck' ? defineAsyncComponent(() => import('@/ui/deck.vue')) : ui === 'classic' ? defineAsyncComponent(() => import('@/ui/classic.vue')) : defineAsyncComponent(() => import('@/ui/universal.vue')), ); diff --git a/packages/client/src/menu.ts b/packages/client/src/menu.ts index dbe85fe4f..6a43fda54 100644 --- a/packages/client/src/menu.ts +++ b/packages/client/src/menu.ts @@ -169,13 +169,6 @@ export const menuDef = reactive({ localStorage.setItem('ui', 'default'); unisonReload(); }, - }, { - text: i18n.ts.deck, - active: ui === 'deck', - action: () => { - localStorage.setItem('ui', 'deck'); - unisonReload(); - }, }, { text: i18n.ts.classic, active: ui === 'classic', diff --git a/packages/client/src/os.ts b/packages/client/src/os.ts index e7ffb99c9..e5ad27585 100644 --- a/packages/client/src/os.ts +++ b/packages/client/src/os.ts @@ -546,8 +546,6 @@ export function post(props: Record = {}) { }); } -export const deckGlobalEvents = new EventEmitter(); - /* export function checkExistence(fileData: ArrayBuffer): Promise { return new Promise((resolve) => { diff --git a/packages/client/src/pages/settings/deck.vue b/packages/client/src/pages/settings/deck.vue deleted file mode 100644 index a037e409b..000000000 --- a/packages/client/src/pages/settings/deck.vue +++ /dev/null @@ -1,73 +0,0 @@ - - - diff --git a/packages/client/src/pages/settings/general.vue b/packages/client/src/pages/settings/general.vue index 28652447f..089c14ff5 100644 --- a/packages/client/src/pages/settings/general.vue +++ b/packages/client/src/pages/settings/general.vue @@ -87,8 +87,6 @@ - {{ i18n.ts.deck }} - {{ i18n.ts.customCss }} diff --git a/packages/client/src/pages/settings/index.vue b/packages/client/src/pages/settings/index.vue index b6a60a4b0..14556554a 100644 --- a/packages/client/src/pages/settings/index.vue +++ b/packages/client/src/pages/settings/index.vue @@ -217,7 +217,6 @@ const component = computed(() => { case 'menu': return defineAsyncComponent(() => import('./menu.vue')); case 'sounds': return defineAsyncComponent(() => import('./sounds.vue')); case 'custom-css': return defineAsyncComponent(() => import('./custom-css.vue')); - case 'deck': return defineAsyncComponent(() => import('./deck.vue')); case 'plugin': return defineAsyncComponent(() => import('./plugin.vue')); case 'plugin/install': return defineAsyncComponent(() => import('./plugin.install.vue')); case 'import-export': return defineAsyncComponent(() => import('./import-export.vue')); diff --git a/packages/client/src/ui/deck.vue b/packages/client/src/ui/deck.vue deleted file mode 100644 index 889aedfbb..000000000 --- a/packages/client/src/ui/deck.vue +++ /dev/null @@ -1,289 +0,0 @@ - - - - - diff --git a/packages/client/src/ui/deck/antenna-column.vue b/packages/client/src/ui/deck/antenna-column.vue deleted file mode 100644 index 77ef5aefb..000000000 --- a/packages/client/src/ui/deck/antenna-column.vue +++ /dev/null @@ -1,63 +0,0 @@ - - - - - diff --git a/packages/client/src/ui/deck/column-core.vue b/packages/client/src/ui/deck/column-core.vue deleted file mode 100644 index 0e9b55818..000000000 --- a/packages/client/src/ui/deck/column-core.vue +++ /dev/null @@ -1,43 +0,0 @@ - - - diff --git a/packages/client/src/ui/deck/column.vue b/packages/client/src/ui/deck/column.vue deleted file mode 100644 index 96c92d3e1..000000000 --- a/packages/client/src/ui/deck/column.vue +++ /dev/null @@ -1,377 +0,0 @@ - - - - - - diff --git a/packages/client/src/ui/deck/deck-store.ts b/packages/client/src/ui/deck/deck-store.ts deleted file mode 100644 index 46f189d71..000000000 --- a/packages/client/src/ui/deck/deck-store.ts +++ /dev/null @@ -1,304 +0,0 @@ -import { throttle } from 'throttle-debounce'; -import { markRaw } from 'vue'; -import { notificationTypes } from 'foundkey-js'; -import { Storage } from '@/pizzax'; -import { i18n } from '@/i18n'; -import { api } from '@/os'; - -type ColumnWidget = { - name: string; - id: string; - data: Record; -}; - -export type Column = { - id: string; - type: string; - name: string | null; - width: number; - widgets?: ColumnWidget[]; - active?: boolean; - flexible?: boolean; - antennaId?: string; - listId?: string; - includingTypes?: typeof notificationTypes[number][]; - tl?: 'home' | 'local' | 'social' | 'global'; -}; - -function copy(x: T): T { - return JSON.parse(JSON.stringify(x)); -} - -export const deckStore = markRaw(new Storage('deck', { - profile: { - where: 'deviceAccount', - default: 'default', - }, - columns: { - where: 'deviceAccount', - default: [] as Column[], - }, - layout: { - where: 'deviceAccount', - default: [] as Column['id'][][], - }, - columnAlign: { - where: 'deviceAccount', - default: 'left' as 'left' | 'right' | 'center', - }, - alwaysShowMainColumn: { - where: 'deviceAccount', - default: true, - }, - navWindow: { - where: 'deviceAccount', - default: true, - }, - columnMargin: { - where: 'deviceAccount', - default: 16, - }, - columnHeaderHeight: { - where: 'deviceAccount', - default: 42, - }, -})); - -export const loadDeck = async () => { - let deck; - - try { - deck = await api('i/registry/get', { - scope: ['client', 'deck', 'profiles'], - key: deckStore.state.profile, - }); - } catch (err) { - if (err.code === 'NO_SUCH_KEY') { - // 後方互換性のため - if (deckStore.state.profile === 'default') { - saveDeck(); - return; - } - - deckStore.set('columns', [{ - id: 'a', - type: 'main', - name: i18n.ts._deck._columns.main, - width: 350, - }, { - id: 'b', - type: 'notifications', - name: i18n.ts._deck._columns.notifications, - width: 330, - }]); - deckStore.set('layout', [['a'], ['b']]); - return; - } - throw err; - } - - deckStore.set('columns', deck.columns); - deckStore.set('layout', deck.layout); -}; - -// TODO: deckがloadされていない状態でsaveすると意図せず上書きが発生するので対策する -export const saveDeck = throttle(1000, () => { - api('i/registry/set', { - scope: ['client', 'deck', 'profiles'], - key: deckStore.state.profile, - value: { - columns: deckStore.reactiveState.columns.value, - layout: deckStore.reactiveState.layout.value, - }, - }); -}); - -export function addColumn(column: Column) { - if (column.name === undefined) column.name = null; - deckStore.push('columns', column); - deckStore.push('layout', [column.id]); - saveDeck(); -} - -export function removeColumn(id: Column['id']) { - deckStore.set('columns', deckStore.state.columns.filter(c => c.id !== id)); - deckStore.set('layout', deckStore.state.layout - .map(ids => ids.filter(_id => _id !== id)) - .filter(ids => ids.length > 0)); - saveDeck(); -} - -export function swapColumn(a: Column['id'], b: Column['id']) { - const aX = deckStore.state.layout.findIndex(ids => ids.indexOf(a) !== -1); - const aY = deckStore.state.layout[aX].findIndex(id => id === a); - const bX = deckStore.state.layout.findIndex(ids => ids.indexOf(b) !== -1); - const bY = deckStore.state.layout[bX].findIndex(id => id === b); - const layout = copy(deckStore.state.layout); - layout[aX][aY] = b; - layout[bX][bY] = a; - deckStore.set('layout', layout); - saveDeck(); -} - -export function swapLeftColumn(id: Column['id']) { - const layout = copy(deckStore.state.layout); - deckStore.state.layout.some((ids, i) => { - if (ids.includes(id)) { - const left = deckStore.state.layout[i - 1]; - if (left) { - layout[i - 1] = deckStore.state.layout[i]; - layout[i] = left; - deckStore.set('layout', layout); - } - return true; - } - }); - saveDeck(); -} - -export function swapRightColumn(id: Column['id']) { - const layout = copy(deckStore.state.layout); - deckStore.state.layout.some((ids, i) => { - if (ids.includes(id)) { - const right = deckStore.state.layout[i + 1]; - if (right) { - layout[i + 1] = deckStore.state.layout[i]; - layout[i] = right; - deckStore.set('layout', layout); - } - return true; - } - }); - saveDeck(); -} - -export function swapUpColumn(id: Column['id']) { - const layout = copy(deckStore.state.layout); - const idsIndex = deckStore.state.layout.findIndex(ids => ids.includes(id)); - const ids = copy(deckStore.state.layout[idsIndex]); - ids.some((x, i) => { - if (x === id) { - const up = ids[i - 1]; - if (up) { - ids[i - 1] = id; - ids[i] = up; - - layout[idsIndex] = ids; - deckStore.set('layout', layout); - } - return true; - } - }); - saveDeck(); -} - -export function swapDownColumn(id: Column['id']) { - const layout = copy(deckStore.state.layout); - const idsIndex = deckStore.state.layout.findIndex(ids => ids.includes(id)); - const ids = copy(deckStore.state.layout[idsIndex]); - ids.some((x, i) => { - if (x === id) { - const down = ids[i + 1]; - if (down) { - ids[i + 1] = id; - ids[i] = down; - - layout[idsIndex] = ids; - deckStore.set('layout', layout); - } - return true; - } - }); - saveDeck(); -} - -export function stackLeftColumn(id: Column['id']) { - let layout = copy(deckStore.state.layout); - const i = deckStore.state.layout.findIndex(ids => ids.includes(id)); - layout = layout.map(ids => ids.filter(_id => _id !== id)); - layout[i - 1].push(id); - layout = layout.filter(ids => ids.length > 0); - deckStore.set('layout', layout); - saveDeck(); -} - -export function popRightColumn(id: Column['id']) { - let layout = copy(deckStore.state.layout); - const i = deckStore.state.layout.findIndex(ids => ids.includes(id)); - const affected = layout[i]; - layout = layout.map(ids => ids.filter(_id => _id !== id)); - layout.splice(i + 1, 0, [id]); - layout = layout.filter(ids => ids.length > 0); - deckStore.set('layout', layout); - - const columns = copy(deckStore.state.columns); - for (const column of columns) { - if (affected.includes(column.id)) { - column.active = true; - } - } - deckStore.set('columns', columns); - - saveDeck(); -} - -export function addColumnWidget(id: Column['id'], widget: ColumnWidget) { - const columns = copy(deckStore.state.columns); - const columnIndex = deckStore.state.columns.findIndex(c => c.id === id); - const column = copy(deckStore.state.columns[columnIndex]); - if (column == null) return; - if (column.widgets == null) column.widgets = []; - column.widgets.unshift(widget); - columns[columnIndex] = column; - deckStore.set('columns', columns); - saveDeck(); -} - -export function removeColumnWidget(id: Column['id'], widget: ColumnWidget) { - const columns = copy(deckStore.state.columns); - const columnIndex = deckStore.state.columns.findIndex(c => c.id === id); - const column = copy(deckStore.state.columns[columnIndex]); - if (column == null) return; - column.widgets = column.widgets.filter(w => w.id !== widget.id); - columns[columnIndex] = column; - deckStore.set('columns', columns); - saveDeck(); -} - -export function setColumnWidgets(id: Column['id'], widgets: ColumnWidget[]) { - const columns = copy(deckStore.state.columns); - const columnIndex = deckStore.state.columns.findIndex(c => c.id === id); - const column = copy(deckStore.state.columns[columnIndex]); - if (column == null) return; - column.widgets = widgets; - columns[columnIndex] = column; - deckStore.set('columns', columns); - saveDeck(); -} - -export function updateColumnWidget(id: Column['id'], widgetId: string, widgetData: any) { - const columns = copy(deckStore.state.columns); - const columnIndex = deckStore.state.columns.findIndex(c => c.id === id); - const column = copy(deckStore.state.columns[columnIndex]); - if (column == null) return; - column.widgets = column.widgets.map(w => w.id === widgetId ? { - ...w, - data: widgetData, - } : w); - columns[columnIndex] = column; - deckStore.set('columns', columns); - saveDeck(); -} - -export function updateColumn(id: Column['id'], column: Partial) { - const columns = copy(deckStore.state.columns); - const columnIndex = deckStore.state.columns.findIndex(c => c.id === id); - const currentColumn = copy(deckStore.state.columns[columnIndex]); - if (currentColumn == null) return; - for (const [k, v] of Object.entries(column)) { - currentColumn[k] = v; - } - columns[columnIndex] = currentColumn; - deckStore.set('columns', columns); - saveDeck(); -} diff --git a/packages/client/src/ui/deck/direct-column.vue b/packages/client/src/ui/deck/direct-column.vue deleted file mode 100644 index 16d4ab1cf..000000000 --- a/packages/client/src/ui/deck/direct-column.vue +++ /dev/null @@ -1,30 +0,0 @@ - - - diff --git a/packages/client/src/ui/deck/list-column.vue b/packages/client/src/ui/deck/list-column.vue deleted file mode 100644 index 4725d8931..000000000 --- a/packages/client/src/ui/deck/list-column.vue +++ /dev/null @@ -1,65 +0,0 @@ - - - - - diff --git a/packages/client/src/ui/deck/main-column.vue b/packages/client/src/ui/deck/main-column.vue deleted file mode 100644 index 392f5b563..000000000 --- a/packages/client/src/ui/deck/main-column.vue +++ /dev/null @@ -1,44 +0,0 @@ - - - diff --git a/packages/client/src/ui/deck/mentions-column.vue b/packages/client/src/ui/deck/mentions-column.vue deleted file mode 100644 index f9db1d217..000000000 --- a/packages/client/src/ui/deck/mentions-column.vue +++ /dev/null @@ -1,27 +0,0 @@ - - - diff --git a/packages/client/src/ui/deck/notifications-column.vue b/packages/client/src/ui/deck/notifications-column.vue deleted file mode 100644 index 5401ff736..000000000 --- a/packages/client/src/ui/deck/notifications-column.vue +++ /dev/null @@ -1,38 +0,0 @@ - - - diff --git a/packages/client/src/ui/deck/tl-column.vue b/packages/client/src/ui/deck/tl-column.vue deleted file mode 100644 index 413f65eec..000000000 --- a/packages/client/src/ui/deck/tl-column.vue +++ /dev/null @@ -1,129 +0,0 @@ - - - - - diff --git a/packages/client/src/ui/deck/widgets-column.vue b/packages/client/src/ui/deck/widgets-column.vue deleted file mode 100644 index fb5e67781..000000000 --- a/packages/client/src/ui/deck/widgets-column.vue +++ /dev/null @@ -1,56 +0,0 @@ - - - - -