Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/enums/pref-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ export type StreamPrefTypeMap = {
export type AllPrefs = GlobalPref | StreamPref;

export const ALL_PREFS: {
global: GlobalPref[],
stream: StreamPref[],
global: Set<GlobalPref>,
stream: Set<StreamPref>,
} = {
global: [
global: new Set([
GlobalPref.AUDIO_MIC_ON_PLAYING,
GlobalPref.AUDIO_VOLUME_CONTROL_ENABLED,
GlobalPref.BLOCK_FEATURES,
Expand Down Expand Up @@ -272,8 +272,8 @@ export const ALL_PREFS: {

GlobalPref.SCRIPT_LOCALE,
GlobalPref.USER_AGENT_PROFILE,
],
stream: [
]),
stream: new Set([
StreamPref.AUDIO_VOLUME,
StreamPref.CONTROLLER_POLLING_RATE,
StreamPref.CONTROLLER_SETTINGS,
Expand Down Expand Up @@ -306,7 +306,7 @@ export const ALL_PREFS: {
StreamPref.VIDEO_RATIO,
StreamPref.VIDEO_SATURATION,
StreamPref.VIDEO_SHARPNESS,
],
]),
} as const;

export type AnySettingsStorage = BaseSettingsStorage<GlobalPref> | BaseSettingsStorage<StreamPref>;
Expand Down
4 changes: 2 additions & 2 deletions src/utils/pref-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ export const setGlobalPref = globalSettingsStorage.setSetting.bind(globalSetting


export function isGlobalPref(prefKey: AnyPref): prefKey is GlobalPref {
return ALL_PREFS.global.includes(prefKey as GlobalPref);
return ALL_PREFS.global.has(prefKey as GlobalPref);
}

export function isStreamPref(prefKey: AnyPref): prefKey is StreamPref {
return ALL_PREFS.stream.includes(prefKey as StreamPref);
return ALL_PREFS.stream.has(prefKey as StreamPref);
}

export function getPrefInfo(prefKey: AnyPref): PrefInfo {
Expand Down
6 changes: 2 additions & 4 deletions src/utils/settings-storages/base-settings-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,8 @@ export class BaseSettingsStorage<T extends AnyPref> {
}
} else if ('multipleOptions' in def) {
if (value.length) {
const validOptions = Object.keys(def.multipleOptions!);
value.forEach((item: any, idx: number) => {
(validOptions.indexOf(item) === -1) && value.splice(idx, 1);
});
const validOptions = new Set(Object.keys(def.multipleOptions!));
value = value.filter((item: any) => validOptions.has(item));
}

if (!value.length) {
Expand Down