diff --git a/src/components/SnippetManagerRedux.tsx b/src/components/SnippetManagerRedux.tsx index ba1f934..ff5908b 100644 --- a/src/components/SnippetManagerRedux.tsx +++ b/src/components/SnippetManagerRedux.tsx @@ -182,15 +182,15 @@ export function SnippetManagerRedux() { }, [dispatch]) const handleSelectAll = useCallback(() => { - if (selectedIds.size === filteredSnippets.length) { + if (selectedIds.length === filteredSnippets.length) { dispatch(clearSelection()) } else { dispatch(selectAllSnippetsAction()) } - }, [dispatch, filteredSnippets.length, selectedIds.size]) + }, [dispatch, filteredSnippets.length, selectedIds.length]) const handleBulkMove = useCallback(async (targetNamespaceId: string) => { - if (selectedIds.size === 0) { + if (selectedIds.length === 0) { toast.error('No snippets selected') return } @@ -202,7 +202,7 @@ export function SnippetManagerRedux() { })).unwrap() const targetNamespace = namespaces.find(n => n.id === targetNamespaceId) - toast.success(`Moved ${selectedIds.size} snippet${selectedIds.size > 1 ? 's' : ''} to ${targetNamespace?.name || 'namespace'}`) + toast.success(`Moved ${selectedIds.length} snippet${selectedIds.length > 1 ? 's' : ''} to ${targetNamespace?.name || 'namespace'}`) if (selectedNamespaceId) { dispatch(fetchSnippetsByNamespace(selectedNamespaceId)) @@ -355,12 +355,12 @@ export function SnippetManagerRedux() { size="sm" onClick={handleSelectAll} > - {selectedIds.size === filteredSnippets.length ? 'Deselect All' : 'Select All'} + {selectedIds.length === filteredSnippets.length ? 'Deselect All' : 'Select All'} - {selectedIds.size > 0 && ( + {selectedIds.length > 0 && ( <> - {selectedIds.size} selected + {selectedIds.length} selected @@ -402,7 +402,7 @@ export function SnippetManagerRedux() { onDelete={handleDeleteSnippet} onCopy={handleCopyCode} selectionMode={selectionMode} - isSelected={selectedIds.has(snippet.id)} + isSelected={selectedIds.includes(snippet.id)} onToggleSelect={handleToggleSnippetSelection} /> ))} diff --git a/src/store/index.ts b/src/store/index.ts index 02fe968..9509ca3 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -11,9 +11,7 @@ export const store = configureStore({ ui: uiReducer, }, middleware: (getDefaultMiddleware) => - getDefaultMiddleware({ - serializableCheck: false, - }).concat(persistenceMiddleware), + getDefaultMiddleware().concat(persistenceMiddleware), devTools: { name: 'CodeSnippet', trace: true, diff --git a/src/store/selectors.ts b/src/store/selectors.ts index 3a35e23..8c729fa 100644 --- a/src/store/selectors.ts +++ b/src/store/selectors.ts @@ -39,5 +39,5 @@ export const selectFilteredSnippets = createSelector( export const selectSelectedSnippets = createSelector( [selectSnippets, selectSelectedIds], - (snippets, selectedIds) => snippets.filter(s => selectedIds.has(s.id)) + (snippets, selectedIds) => snippets.filter(s => selectedIds.includes(s.id)) ) diff --git a/src/store/slices/snippetsSlice.ts b/src/store/slices/snippetsSlice.ts index 603ac3e..23fa06f 100644 --- a/src/store/slices/snippetsSlice.ts +++ b/src/store/slices/snippetsSlice.ts @@ -13,7 +13,7 @@ interface SnippetsState { items: Snippet[] loading: boolean error: string | null - selectedIds: Set + selectedIds: string[] selectionMode: boolean } @@ -21,7 +21,7 @@ const initialState: SnippetsState = { items: [], loading: false, error: null, - selectedIds: new Set(), + selectedIds: [], selectionMode: false, } @@ -88,23 +88,22 @@ const snippetsSlice = createSlice({ toggleSelectionMode: (state) => { state.selectionMode = !state.selectionMode if (!state.selectionMode) { - state.selectedIds = new Set() + state.selectedIds = [] } }, toggleSnippetSelection: (state, action: PayloadAction) => { - const newSet = new Set(state.selectedIds) - if (newSet.has(action.payload)) { - newSet.delete(action.payload) + const index = state.selectedIds.indexOf(action.payload) + if (index !== -1) { + state.selectedIds.splice(index, 1) } else { - newSet.add(action.payload) + state.selectedIds.push(action.payload) } - state.selectedIds = newSet }, clearSelection: (state) => { - state.selectedIds = new Set() + state.selectedIds = [] }, selectAllSnippets: (state) => { - state.selectedIds = new Set(state.items.map(s => s.id)) + state.selectedIds = state.items.map(s => s.id) }, }, extraReducers: (builder) => { @@ -152,7 +151,7 @@ const snippetsSlice = createSlice({ snippet.namespaceId = targetNamespaceId } }) - state.selectedIds = new Set() + state.selectedIds = [] state.selectionMode = false }) },