Skip to content

Commit 78accc8

Browse files
Copilothotlong
andcommitted
refactor: address code review — extract duplicate filter in useNavPins togglePin
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 24707f3 commit 78accc8

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

apps/console/src/hooks/useNavPins.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ export function useNavPins() {
4343

4444
const togglePin = useCallback((itemId: string, pinned: boolean) => {
4545
setPinnedIds(prev => {
46+
const filtered = prev.filter(id => id !== itemId);
4647
const updated = pinned
47-
? [...prev.filter(id => id !== itemId), itemId].slice(0, MAX_PINS)
48-
: prev.filter(id => id !== itemId);
48+
? [...filtered, itemId].slice(0, MAX_PINS)
49+
: filtered;
4950
savePins(updated);
5051
return updated;
5152
});

0 commit comments

Comments
 (0)