summaryrefslogtreecommitdiff
path: root/packages/client/src/store.ts
diff options
context:
space:
mode:
authorKagami Sascha Rosylight <saschanaz@outlook.com>2022-12-18 13:13:05 +0900
committerGitHub <noreply@github.com>2022-12-18 13:13:05 +0900
commitbb3d274db64fe662ad01780ca5eadbc263f6f759 (patch)
tree2fcd6dfb55cabad77441a6d3cdb2ef5fbec075e2 /packages/client/src/store.ts
parentRemove redundant ts-node things (#9335) (diff)
downloadsharkey-bb3d274db64fe662ad01780ca5eadbc263f6f759.tar.gz
sharkey-bb3d274db64fe662ad01780ca5eadbc263f6f759.tar.bz2
sharkey-bb3d274db64fe662ad01780ca5eadbc263f6f759.zip
refactor(client): add proper types to `never[]` (#9340)
Diffstat (limited to 'packages/client/src/store.ts')
-rw-r--r--packages/client/src/store.ts41
1 files changed, 35 insertions, 6 deletions
diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts
index 3971214af0..061e1913d6 100644
--- a/packages/client/src/store.ts
+++ b/packages/client/src/store.ts
@@ -2,11 +2,34 @@ import { markRaw, ref } from 'vue';
import { Storage } from './pizzax';
import { Theme } from './scripts/theme';
-export const postFormActions = [];
-export const userActions = [];
-export const noteActions = [];
-export const noteViewInterruptors = [];
-export const notePostInterruptors = [];
+interface PostFormAction {
+ title: string,
+ handler: <T>(form: T, update: (key: unknown, value: unknown) => void) => void;
+}
+
+interface UserAction {
+ title: string,
+ handler: (user: UserDetailed) => void;
+}
+
+interface NoteAction {
+ title: string,
+ handler: (note: Note) => void;
+}
+
+interface NoteViewInterruptor {
+ handler: (note: Note) => unknown;
+}
+
+interface NotePostInterruptor {
+ handler: (note: FIXME) => unknown;
+}
+
+export const postFormActions: PostFormAction[] = [];
+export const userActions: UserAction[] = [];
+export const noteActions: NoteAction[] = [];
+export const noteViewInterruptors: NoteViewInterruptor[] = [];
+export const notePostInterruptors: NotePostInterruptor[] = [];
// TODO: それぞれいちいちwhereとかdefaultというキーを付けなきゃいけないの冗長なのでなんとかする(ただ型定義が面倒になりそう)
// あと、現行の定義の仕方なら「whereが何であるかに関わらずキー名の重複不可」という制約を付けられるメリットもあるからそのメリットを引き継ぐ方法も考えないといけない
@@ -266,11 +289,17 @@ type Plugin = {
ast: any[];
};
+interface Watcher {
+ key: string;
+ callback: (value: unknown) => void;
+}
+
/**
* 常にメモリにロードしておく必要がないような設定情報を保管するストレージ(非リアクティブ)
*/
import lightTheme from '@/themes/l-light.json5';
import darkTheme from '@/themes/d-green-lime.json5';
+import { Note, UserDetailed } from 'misskey-js/built/entities';
export class ColdDeviceStorage {
public static default = {
@@ -289,7 +318,7 @@ export class ColdDeviceStorage {
sound_channel: { type: 'syuilo/square-pico', volume: 1 },
};
- public static watchers = [];
+ public static watchers: Watcher[] = [];
public static get<T extends keyof typeof ColdDeviceStorage.default>(key: T): typeof ColdDeviceStorage.default[T] {
// TODO: indexedDBにする