1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-24 11:34:10 +02:00
This commit is contained in:
syuilo
2025-08-26 13:34:41 +09:00
parent eb9915baf8
commit d6a1046361
41 changed files with 289 additions and 140 deletions

View File

@@ -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();

View File

@@ -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;
}
}