Skip to content

Commit 092d2b7

Browse files
committed
fix: optimize card order update logic in user preferences
1 parent 6a71b1f commit 092d2b7

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/stores/preferences.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import arrayMove from 'array-move'
21
import { Occupation } from 'src/features/onboarding/types'
32
import { Tag, useRemoteConfigStore } from 'src/features/remoteConfig'
43
import { enhanceTags } from 'src/utils/DataEnhancement'
@@ -174,7 +173,11 @@ export const useUserPreferences = create(
174173
setUserCustomCards: (cards: SupportedCardType[]) => set({ userCustomCards: cards }),
175174
updateCardOrder: (prevIndex: number, newIndex: number) =>
176175
set((state) => {
177-
const newState = arrayMove(state.cards, prevIndex, newIndex).map((card, index) => {
176+
const updated = [...state.cards]
177+
const [movedItem] = updated.splice(prevIndex, 1)
178+
updated.splice(newIndex, 0, movedItem)
179+
180+
const newState = updated.map((card, index) => {
178181
return {
179182
...card,
180183
id: index,

0 commit comments

Comments
 (0)