mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-15 04:51:06 +02:00
feat: add regex filter setting for sidebar playlists (#1589)
* added regex filter for sidebar playlists --------- Co-authored-by: jeffvli <jeffvictorli@gmail.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ChangeEvent, memo } from 'react';
|
||||
import { ChangeEvent, memo, useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { SidebarReorder } from '/@/renderer/features/settings/components/general/sidebar-reorder';
|
||||
@@ -8,6 +8,8 @@ import {
|
||||
} from '/@/renderer/features/settings/components/settings-section';
|
||||
import { useGeneralSettings, useSettingsStoreActions } from '/@/renderer/store';
|
||||
import { Switch } from '/@/shared/components/switch/switch';
|
||||
import { TextInput } from '/@/shared/components/text-input/text-input';
|
||||
import { useDebouncedCallback } from '/@/shared/hooks/use-debounced-callback';
|
||||
|
||||
export const SidebarSettings = memo(() => {
|
||||
const { t } = useTranslation();
|
||||
@@ -38,6 +40,22 @@ export const SidebarSettings = memo(() => {
|
||||
});
|
||||
};
|
||||
|
||||
const [localFilterRegex, setLocalFilterRegex] = useState(
|
||||
settings.sidebarPlaylistListFilterRegex,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setLocalFilterRegex(settings.sidebarPlaylistListFilterRegex);
|
||||
}, [settings.sidebarPlaylistListFilterRegex]);
|
||||
|
||||
const debouncedSetFilterRegex = useDebouncedCallback((value: string) => {
|
||||
setSettings({
|
||||
general: {
|
||||
sidebarPlaylistListFilterRegex: value,
|
||||
},
|
||||
});
|
||||
}, 500);
|
||||
|
||||
const options: SettingOption[] = [
|
||||
{
|
||||
control: (
|
||||
@@ -52,6 +70,26 @@ export const SidebarSettings = memo(() => {
|
||||
}),
|
||||
title: t('setting.sidebarPlaylistList', { postProcess: 'sentenceCase' }),
|
||||
},
|
||||
{
|
||||
control: (
|
||||
<TextInput
|
||||
onChange={(e) => {
|
||||
const value = e.currentTarget.value;
|
||||
setLocalFilterRegex(value);
|
||||
debouncedSetFilterRegex(value);
|
||||
}}
|
||||
placeholder={t('setting.sidebarPlaylistListFilterRegex_placeholder', {
|
||||
postProcess: 'sentenceCase',
|
||||
})}
|
||||
value={localFilterRegex}
|
||||
/>
|
||||
),
|
||||
description: t('setting.sidebarPlaylistListFilterRegex', {
|
||||
context: 'description',
|
||||
postProcess: 'sentenceCase',
|
||||
}),
|
||||
title: t('setting.sidebarPlaylistListFilterRegex', { postProcess: 'sentenceCase' }),
|
||||
},
|
||||
{
|
||||
control: (
|
||||
<Switch
|
||||
|
||||
Reference in New Issue
Block a user