mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-24 11:34:10 +02:00
refactor
This commit is contained in:
@@ -32,6 +32,8 @@ export type SoundStore = {
|
||||
volume: number;
|
||||
};
|
||||
|
||||
type OmitStrict<T, K extends keyof T> = T extends any ? Pick<T, Exclude<keyof T, K>> : never;
|
||||
|
||||
// NOTE: デフォルト値は他の設定の状態に依存してはならない(依存していた場合、ユーザーがその設定項目単体で「初期値にリセット」した場合不具合の原因になる)
|
||||
|
||||
export const PREF_DEF = definePreferences({
|
||||
@@ -385,7 +387,7 @@ export const PREF_DEF = definePreferences({
|
||||
default: false,
|
||||
},
|
||||
plugins: {
|
||||
default: [] as Plugin[],
|
||||
default: [] as (OmitStrict<Plugin, 'config'> & { config: Record<string, any> })[],
|
||||
mergeStrategy: (a, b) => {
|
||||
const sameIdExists = a.some(x => b.some(y => x.installId === y.installId));
|
||||
if (sameIdExists) throw new Error();
|
||||
|
||||
@@ -109,10 +109,11 @@ export function definePreferences<T extends Record<string, unknown>>(x: {
|
||||
}
|
||||
|
||||
export function getInitialPrefValue<K extends keyof PREF>(k: K): ValueOf<K> {
|
||||
if (typeof PREF_DEF[k].default === 'function') { // factory
|
||||
return PREF_DEF[k].default();
|
||||
const _default = PREF_DEF[k as string].default;
|
||||
if (typeof _default === 'function') { // factory
|
||||
return _default();
|
||||
} else {
|
||||
return PREF_DEF[k].default;
|
||||
return _default;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user