mirror of
https://github.com/stablyai/orca.git
synced 2026-10-23 16:03:49 +00:00
fix(workspace-cleanup): unify chip clears on the merged updater form
#15298 landed the functional-update `patchFilters`, so `replaceFilters` uses the same idiom rather than reading the store directly. Same guarantee, one pattern.
This commit is contained in:
-1
@@ -105,7 +105,6 @@ describe('useWorkspaceCleanupBrowseState', () => {
|
||||
field: 'size',
|
||||
direction: 'desc'
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps a cleared chip cleared when a facet patch lands in the same tick', () => {
|
||||
|
||||
@@ -60,12 +60,11 @@ export function useWorkspaceCleanupBrowseState(): WorkspaceCleanupBrowseControll
|
||||
[updateBrowse]
|
||||
)
|
||||
|
||||
// Why read the store rather than the rendered `browse`: a chip click and any other
|
||||
// filter write can land in the same tick, and the rendered snapshot would drop one.
|
||||
// Same updater form as patchFilters: a chip clear and a facet patch can land in one
|
||||
// tick, and whichever read the render snapshot would undo the other.
|
||||
const replaceFilters = useCallback<WorkspaceCleanupBrowseController['replaceFilters']>(
|
||||
(transform) => {
|
||||
const current = useAppStore.getState().workspaceCleanupBrowse
|
||||
updateBrowse({ ...current, filters: transform(current.filters) })
|
||||
updateBrowse((current) => ({ ...current, filters: transform(current.filters) }))
|
||||
},
|
||||
[updateBrowse]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user