add skip to duplicates to playlist ctx menu - persist value

This commit is contained in:
jeffvli
2025-12-07 12:39:28 -08:00
parent 20a6fcbeb7
commit d8b190c2b7
2 changed files with 83 additions and 5 deletions
@@ -37,6 +37,7 @@ import { TextInput } from '/@/shared/components/text-input/text-input';
import { Text } from '/@/shared/components/text/text';
import { toast } from '/@/shared/components/toast/toast';
import { useForm } from '/@/shared/hooks/use-form';
import { useLocalStorage } from '/@/shared/hooks/use-local-storage';
import { Playlist, PlaylistListSort, SortOrder } from '/@/shared/types/domain-types';
export const AddToPlaylistContextModal = ({
@@ -61,14 +62,23 @@ export const AddToPlaylistContextModal = ({
const rowRefs = useRef<(HTMLTableRowElement | null)[]>([]);
const formRef = useRef<HTMLFormElement>(null);
const [skipDuplicates, setSkipDuplicates] = useLocalStorage({
defaultValue: true,
key: 'playlist-skip-duplicate',
});
const form = useForm({
initialValues: {
newPlaylists: [] as string[],
selectedPlaylistIds: initialSelectedIds || [],
skipDuplicates: true,
skipDuplicates: skipDuplicates,
},
});
form.watch('skipDuplicates', (event) => {
setSkipDuplicates(event.value);
});
const addToPlaylistMutation = useAddToPlaylist({});
const playlistList = useQuery(