summaryrefslogtreecommitdiff
path: root/packages/frontend/src/store.ts
diff options
context:
space:
mode:
authorHazelnoot <acomputerdog@gmail.com>2025-03-25 16:14:53 -0400
committerHazelnoot <acomputerdog@gmail.com>2025-03-25 16:14:53 -0400
commitd8908ef2d8fa84d8e0fc1d30ab90a600a3d88054 (patch)
tree0c8d3e0385ce7021c7187ef8b608f1abd87496e5 /packages/frontend/src/store.ts
parentmerge: enhance: Update de-DE.yml (!949) (diff)
parentenhance(frontend): 設定の移行を手動でトリガーできるように (diff)
downloadsharkey-d8908ef2d8fa84d8e0fc1d30ab90a600a3d88054.tar.gz
sharkey-d8908ef2d8fa84d8e0fc1d30ab90a600a3d88054.tar.bz2
sharkey-d8908ef2d8fa84d8e0fc1d30ab90a600a3d88054.zip
merge upstream
Diffstat (limited to 'packages/frontend/src/store.ts')
-rw-r--r--packages/frontend/src/store.ts353
1 files changed, 149 insertions, 204 deletions
diff --git a/packages/frontend/src/store.ts b/packages/frontend/src/store.ts
index 69fcef32c2..0ba1a17969 100644
--- a/packages/frontend/src/store.ts
+++ b/packages/frontend/src/store.ts
@@ -5,70 +5,21 @@
import { markRaw, ref } from 'vue';
import * as Misskey from 'misskey-js';
+import { searchEngineMap } from '@/utility/search-engine-map.js';
+import lightTheme from '@@/themes/l-light.json5';
+import darkTheme from '@@/themes/d-green-lime.json5';
import { hemisphere } from '@@/js/intl-const.js';
-import lightTheme from '@@/themes/l-cherry.json5';
-import darkTheme from '@@/themes/d-ice.json5';
-import { searchEngineMap } from './scripts/search-engine-map.js';
-import type { SoundType } from '@/scripts/sound.js';
-import type { Ast } from '@syuilo/aiscript';
-import { DEFAULT_DEVICE_KIND, type DeviceKind } from '@/scripts/device-kind.js';
+import type { DeviceKind } from '@/utility/device-kind.js';
+import type { Plugin } from '@/plugin.js';
import { miLocalStorage } from '@/local-storage.js';
-import { defaultFollowingFeedState } from '@/scripts/following-feed-utils.js';
-import { Storage } from '@/pizzax.js';
+import { Pizzax } from '@/lib/pizzax.js';
+import { DEFAULT_DEVICE_KIND } from '@/utility/device-kind.js';
+import { defaultFollowingFeedState } from '@/utility/following-feed-utils.js';
-interface PostFormAction {
- title: string,
- handler: <T>(form: T, update: (key: unknown, value: unknown) => void) => void;
-}
-
-interface UserAction {
- title: string,
- handler: (user: Misskey.entities.UserDetailed) => void;
-}
-
-interface NoteAction {
- title: string,
- handler: (note: Misskey.entities.Note) => void;
-}
-
-interface NoteViewInterruptor {
- handler: (note: Misskey.entities.Note) => unknown;
-}
-
-interface NotePostInterruptor {
- handler: (note: FIXME) => unknown;
-}
-
-interface PageViewInterruptor {
- handler: (page: Misskey.entities.Page) => unknown;
-}
-
-/** サウンド設定 */
-export type SoundStore = {
- type: Exclude<SoundType, '_driveFile_'>;
- volume: number;
-} | {
- type: '_driveFile_';
-
- /** ドライブのファイルID */
- fileId: string;
-
- /** ファイルURL(こちらが優先される) */
- fileUrl: string;
-
- volume: number;
-}
-
-export const postFormActions: PostFormAction[] = [];
-export const userActions: UserAction[] = [];
-export const noteActions: NoteAction[] = [];
-export const noteViewInterruptors: NoteViewInterruptor[] = [];
-export const notePostInterruptors: NotePostInterruptor[] = [];
-export const pageViewInterruptors: PageViewInterruptor[] = [];
-
-// TODO: それぞれいちいちwhereとかdefaultというキーを付けなきゃいけないの冗長なのでなんとかする(ただ型定義が面倒になりそう)
-// あと、現行の定義の仕方なら「whereが何であるかに関わらずキー名の重複不可」という制約を付けられるメリットもあるからそのメリットを引き継ぐ方法も考えないといけない
-export const defaultStore = markRaw(new Storage('base', {
+/**
+ * 「状態」を管理するストア(not「設定」)
+ */
+export const store = markRaw(new Pizzax('base', {
accountSetupWizard: {
where: 'account',
default: 0,
@@ -86,18 +37,103 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'account',
default: false,
},
- keepCw: {
+ memo: {
where: 'account',
- default: true,
+ default: null,
},
- showFullAcct: {
+ reactionAcceptance: {
+ where: 'account',
+ default: 'nonSensitiveOnly' as 'likeOnly' | 'likeOnlyForRemote' | 'nonSensitiveOnly' | 'nonSensitiveOnlyForLocalLikeOnlyForRemote' | null,
+ },
+ mutedAds: {
where: 'account',
+ default: [] as string[],
+ },
+ visibility: {
+ where: 'deviceAccount',
+ default: 'public' as (typeof Misskey.noteVisibilities)[number],
+ },
+ localOnly: {
+ where: 'deviceAccount',
default: false,
},
- collapseRenotes: {
+ showPreview: {
+ where: 'device',
+ default: false,
+ },
+ tl: {
+ where: 'deviceAccount',
+ default: {
+ src: 'home' as 'home' | 'local' | 'social' | 'global' | 'bubble' | `list:${string}`,
+ userList: null as Misskey.entities.UserList | null,
+ filter: {
+ withReplies: true,
+ withRenotes: true,
+ withSensitive: true,
+ onlyFiles: false,
+ withBots: true,
+ },
+ },
+ },
+ darkMode: {
+ where: 'device',
+ default: false,
+ },
+ recentlyUsedEmojis: {
+ where: 'device',
+ default: [] as string[],
+ },
+ recentlyUsedUsers: {
+ where: 'device',
+ default: [] as string[],
+ },
+ menuDisplay: {
+ where: 'device',
+ default: 'sideFull' as 'sideFull' | 'sideIcon' | 'top',
+ },
+ postFormWithHashtags: {
+ where: 'device',
+ default: false,
+ },
+ postFormHashtags: {
+ where: 'device',
+ default: '',
+ },
+ additionalUnicodeEmojiIndexes: {
+ where: 'device',
+ default: {} as Record<string, Record<string, string[]>>,
+ },
+ pluginTokens: {
+ where: 'deviceAccount',
+ default: {} as Record<string, string>, // plugin id, token
+ },
+ accountTokens: {
+ where: 'device',
+ default: {} as Record<string, string>, // host/userId, token
+ },
+
+ enablePreferencesAutoCloudBackup: {
+ where: 'device',
+ default: false,
+ },
+ showPreferencesAutoCloudBackupSuggestion: {
+ where: 'device',
+ default: true,
+ },
+
+ //#region TODO: そのうち消す (preferに移行済み)
+ defaultWithReplies: {
where: 'account',
default: false,
},
+ reactions: {
+ where: 'account',
+ default: ['👍', '❤️', '😆', '🤔', '😮', '🎉', '💢', '😥', '😇', '🍮'],
+ },
+ pinnedEmojis: {
+ where: 'account',
+ default: [],
+ },
collapseNotesRepliedTo: {
where: 'account',
default: false,
@@ -114,8 +150,21 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'device',
default: false,
},
- rememberNoteVisibility: {
+ widgets: {
where: 'account',
+ default: [] as {
+ name: string;
+ id: string;
+ place: string | null;
+ data: Record<string, any>;
+ }[],
+ },
+ overridedDeviceKind: {
+ where: 'device',
+ default: null as DeviceKind | null,
+ },
+ defaultSideView: {
+ where: 'device',
default: false,
},
defaultNoteVisibility: {
@@ -126,42 +175,30 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'account',
default: false,
},
- uploadFolder: {
+ keepCw: {
where: 'account',
- default: null as string | null,
+ default: true,
},
- pastedFileName: {
+ collapseRenotes: {
where: 'account',
- default: 'yyyy-MM-dd HH-mm-ss [{{number}}]',
+ default: true,
},
- keepOriginalUploading: {
+ rememberNoteVisibility: {
where: 'account',
default: false,
},
- memo: {
- where: 'account',
- default: null,
- },
- reactions: {
- where: 'account',
- default: ['👍', '❤️', '😆', '🤔', '😮', '🎉', '💢', '😥', '😇', '🍮'],
- },
- pinnedEmojis: {
+ uploadFolder: {
where: 'account',
- default: [],
+ default: null as string | null,
},
- reactionAcceptance: {
+ keepOriginalUploading: {
where: 'account',
- default: 'nonSensitiveOnly' as 'likeOnly' | 'likeOnlyForRemote' | 'nonSensitiveOnly' | 'nonSensitiveOnlyForLocalLikeOnlyForRemote' | null,
+ default: false,
},
like: {
where: 'account',
default: null as string | null,
},
- mutedAds: {
- where: 'account',
- default: [] as string[],
- },
autoloadConversation: {
where: 'account',
default: true,
@@ -182,7 +219,6 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'account',
default: true,
},
-
menu: {
where: 'deviceAccount',
default: [
@@ -198,18 +234,6 @@ export const defaultStore = markRaw(new Storage('base', {
'achievements',
],
},
- visibility: {
- where: 'deviceAccount',
- default: 'public' as (typeof Misskey.noteVisibilities)[number],
- },
- localOnly: {
- where: 'deviceAccount',
- default: false,
- },
- showPreview: {
- where: 'device',
- default: false,
- },
statusbars: {
where: 'deviceAccount',
default: [] as {
@@ -221,29 +245,6 @@ export const defaultStore = markRaw(new Storage('base', {
props: Record<string, any>;
}[],
},
- widgets: {
- where: 'account',
- default: [] as {
- name: string;
- id: string;
- place: string | null;
- data: Record<string, any>;
- }[],
- },
- tl: {
- where: 'deviceAccount',
- default: {
- src: 'home' as 'home' | 'local' | 'social' | 'global' | 'bubble' | `list:${string}`,
- userList: null as Misskey.entities.UserList | null,
- filter: {
- withReplies: true,
- withRenotes: true,
- withBots: true,
- withSensitive: true,
- onlyFiles: false,
- },
- },
- },
pinnedUserLists: {
where: 'deviceAccount',
default: [] as Misskey.entities.UserList[],
@@ -252,11 +253,6 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'account',
default: defaultFollowingFeedState,
},
-
- overridedDeviceKind: {
- where: 'device',
- default: null as DeviceKind | null,
- },
serverDisconnectedBehavior: {
where: 'device',
default: 'disabled' as 'quiet' | 'dialog' | 'disabled',
@@ -361,10 +357,6 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'device',
default: false,
},
- darkMode: {
- where: 'device',
- default: false,
- },
instanceTicker: {
where: 'device',
default: 'remote' as 'none' | 'remote' | 'always',
@@ -385,22 +377,6 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'device',
default: 'auto' as 'auto' | 'popup' | 'drawer',
},
- recentlyUsedEmojis: {
- where: 'device',
- default: [] as string[],
- },
- recentlyUsedUsers: {
- where: 'device',
- default: [] as string[],
- },
- defaultSideView: {
- where: 'device',
- default: false,
- },
- menuDisplay: {
- where: 'device',
- default: 'sideFull' as 'sideFull' | 'sideIcon' | 'top',
- },
reportError: {
where: 'device',
default: false,
@@ -413,18 +389,6 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'device',
default: true,
},
- postFormWithHashtags: {
- where: 'device',
- default: false,
- },
- postFormHashtags: {
- where: 'device',
- default: '',
- },
- themeInitial: {
- where: 'device',
- default: true,
- },
numberOfPageCache: {
where: 'device',
default: 3,
@@ -489,18 +453,10 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'device',
default: true,
},
- additionalUnicodeEmojiIndexes: {
- where: 'device',
- default: {} as Record<string, Record<string, string[]>>,
- },
keepScreenOn: {
where: 'device',
default: false,
},
- defaultWithReplies: {
- where: 'account',
- default: false,
- },
disableStreamingTimeline: {
where: 'device',
default: false,
@@ -522,17 +478,6 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'device',
default: false,
},
- dropAndFusion: {
- where: 'device',
- default: {
- bgmVolume: 0.25,
- sfxVolume: 1,
- },
- },
- hemisphere: {
- where: 'device',
- default: hemisphere as 'N' | 'S',
- },
enableHorizontalSwipe: {
where: 'device',
default: true,
@@ -565,7 +510,14 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'device',
default: false,
},
-
+ confirmOnReact: {
+ where: 'device',
+ default: false,
+ },
+ hemisphere: {
+ where: 'device',
+ default: hemisphere as 'N' | 'S',
+ },
sound_masterVolume: {
where: 'device',
default: 0.3,
@@ -580,56 +532,49 @@ export const defaultStore = markRaw(new Storage('base', {
},
sound_note: {
where: 'device',
- default: { type: 'syuilo/n-aec', volume: 0 } as SoundStore,
+ default: { type: 'syuilo/n-aec', volume: 1 },
},
sound_noteMy: {
where: 'device',
- default: { type: 'syuilo/n-cea-4va', volume: 1 } as SoundStore,
+ default: { type: 'syuilo/n-cea-4va', volume: 1 },
},
sound_notification: {
where: 'device',
- default: { type: 'syuilo/n-ea', volume: 1 } as SoundStore,
+ default: { type: 'syuilo/n-ea', volume: 1 },
},
sound_reaction: {
where: 'device',
- default: { type: 'syuilo/bubble2', volume: 1 } as SoundStore,
+ default: { type: 'syuilo/bubble2', volume: 1 },
+ },
+ dropAndFusion: {
+ where: 'device',
+ default: {
+ bgmVolume: 0.25,
+ sfxVolume: 1,
+ },
},
+ //#endregion
}));
// TODO: 他のタブと永続化されたstateを同期
const PREFIX = 'miux:' as const;
-export type Plugin = {
- id: string;
- name: string;
- active: boolean;
- config?: Record<string, { default: any }>;
- configData: Record<string, any>;
- token: string;
- src: string | null;
- version: string;
- ast: Ast.Node[];
- author?: string;
- description?: string;
- permissions?: string[];
-};
-
interface Watcher {
key: string;
callback: (value: unknown) => void;
}
+// TODO: 消す(preferに移行済みのため)
/**
* 常にメモリにロードしておく必要がないような設定情報を保管するストレージ(非リアクティブ)
*/
-
export class ColdDeviceStorage {
public static default = {
- lightTheme,
- darkTheme,
- syncDeviceDarkMode: true,
- plugins: [] as Plugin[],
+ lightTheme, // TODO: 消す(preferに移行済みのため)
+ darkTheme, // TODO: 消す(preferに移行済みのため)
+ syncDeviceDarkMode: true, // TODO: 消す(preferに移行済みのため)
+ plugins: [] as Plugin[], // TODO: 消す(preferに移行済みのため)
};
public static watchers: Watcher[] = [];