mirror of
https://github.com/jeffvli/feishin.git
synced 2026-07-23 02:46:40 +02:00
add album mode for autodj
- add selection modes: similar, random - add autodj settings in playerbar popover
This commit is contained in:
@@ -111,6 +111,8 @@ const SIDE_QUEUE_TYPES = new Set(['sideDrawerQueue', 'sideQueue']);
|
||||
const SIDE_QUEUE_LAYOUTS = new Set(['horizontal', 'vertical']);
|
||||
const SIDEBAR_PLAYLIST_FOLDER_VIEWS = new Set(['navigation', 'single', 'tree']);
|
||||
const SIDEBAR_PLAYLIST_MODES = new Set(['compact', 'expanded']);
|
||||
const AUTO_DJ_MODES = new Set(['albums', 'songs']);
|
||||
const AUTO_DJ_STRATEGIES = new Set(['library_random', 'similar']);
|
||||
|
||||
export type EnvSettingsOverrides = DeepPartial<
|
||||
Pick<SettingsState, 'autoDJ' | 'css' | 'discord' | 'font' | 'general' | 'lyrics' | 'playback'>
|
||||
@@ -422,8 +424,21 @@ const ENV_SETTING_SPECS: EnvSettingSpec[] = [
|
||||
path: ['lyrics', 'alignment'],
|
||||
type: 'enum',
|
||||
},
|
||||
{
|
||||
enumSet: AUTO_DJ_STRATEGIES,
|
||||
key: 'FS_AUTO_DJ_ALBUM_STRATEGY',
|
||||
path: ['autoDJ', 'albumStrategy'],
|
||||
type: 'enum',
|
||||
},
|
||||
{ key: 'FS_AUTO_DJ_ENABLED', path: ['autoDJ', 'enabled'], type: 'bool' },
|
||||
{ key: 'FS_AUTO_DJ_ITEM_COUNT', path: ['autoDJ', 'itemCount'], type: 'num' },
|
||||
{ enumSet: AUTO_DJ_MODES, key: 'FS_AUTO_DJ_MODE', path: ['autoDJ', 'mode'], type: 'enum' },
|
||||
{
|
||||
enumSet: AUTO_DJ_STRATEGIES,
|
||||
key: 'FS_AUTO_DJ_SONG_STRATEGY',
|
||||
path: ['autoDJ', 'songStrategy'],
|
||||
type: 'enum',
|
||||
},
|
||||
{ key: 'FS_AUTO_DJ_TIMING', path: ['autoDJ', 'timing'], type: 'num' },
|
||||
{
|
||||
key: 'FS_CSS_CONTENT',
|
||||
|
||||
@@ -675,9 +675,28 @@ const QueryBuilderSettingsSchema = z.object({
|
||||
tag: z.array(QueryBuilderCustomFieldSchema),
|
||||
});
|
||||
|
||||
export const AUTO_DJ_MODE = {
|
||||
ALBUMS: 'albums',
|
||||
SONGS: 'songs',
|
||||
} as const;
|
||||
|
||||
export type AutoDJMode = (typeof AUTO_DJ_MODE)[keyof typeof AUTO_DJ_MODE];
|
||||
|
||||
export const AUTO_DJ_STRATEGY = {
|
||||
LIBRARY_RANDOM: 'library_random',
|
||||
SIMILAR: 'similar',
|
||||
} as const;
|
||||
|
||||
export type AutoDJStrategy = (typeof AUTO_DJ_STRATEGY)[keyof typeof AUTO_DJ_STRATEGY];
|
||||
|
||||
const autoDjStrategyEnum = z.enum(['similar', 'library_random']);
|
||||
|
||||
const AutoDJSettingsSchema = z.object({
|
||||
albumStrategy: autoDjStrategyEnum,
|
||||
enabled: z.boolean(),
|
||||
itemCount: z.number(),
|
||||
mode: z.enum(['songs', 'albums']),
|
||||
songStrategy: autoDjStrategyEnum,
|
||||
timing: z.number(),
|
||||
});
|
||||
|
||||
@@ -1091,8 +1110,11 @@ const platformDefaultWindowBarStyle: Platform = getPlatformDefaultWindowBarStyle
|
||||
|
||||
const initialState: SettingsState = {
|
||||
autoDJ: {
|
||||
albumStrategy: AUTO_DJ_STRATEGY.SIMILAR,
|
||||
enabled: false,
|
||||
itemCount: 5,
|
||||
mode: 'songs',
|
||||
songStrategy: AUTO_DJ_STRATEGY.SIMILAR,
|
||||
timing: 1,
|
||||
},
|
||||
css: {
|
||||
@@ -2427,10 +2449,41 @@ export const useSettingsStore = createWithEqualityFn<SettingsSlice>()(
|
||||
}
|
||||
}
|
||||
|
||||
if (version < 28) {
|
||||
if (!state.autoDJ) {
|
||||
state.autoDJ = { ...initialState.autoDJ };
|
||||
}
|
||||
|
||||
if (state.autoDJ.mode !== 'albums' && state.autoDJ.mode !== 'songs') {
|
||||
state.autoDJ.mode = initialState.autoDJ.mode;
|
||||
}
|
||||
|
||||
const normalizeAutoDjStrategy = (stored: unknown) => {
|
||||
if (stored === 'library_random') {
|
||||
return AUTO_DJ_STRATEGY.LIBRARY_RANDOM;
|
||||
}
|
||||
|
||||
if (
|
||||
stored === 'similar' ||
|
||||
stored === 'default' ||
|
||||
stored === 'similar_forward'
|
||||
) {
|
||||
return AUTO_DJ_STRATEGY.SIMILAR;
|
||||
}
|
||||
|
||||
return initialState.autoDJ.songStrategy;
|
||||
};
|
||||
|
||||
state.autoDJ.songStrategy = normalizeAutoDjStrategy(state.autoDJ.songStrategy);
|
||||
state.autoDJ.albumStrategy = normalizeAutoDjStrategy(
|
||||
state.autoDJ.albumStrategy,
|
||||
);
|
||||
}
|
||||
|
||||
return persistedState;
|
||||
},
|
||||
name: 'store_settings',
|
||||
version: 27,
|
||||
version: 28,
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user