Keeps a list narrowed to one category, whatever the socket puts in it.

Functions

f
useCategoryFilter<T extends { categoryIds?: string[]; }>(
setItems: (fn: (prev: T[]) => T[]) => void,
categoryId?: string
): (fn: (prev: T[]) => T[]) => void

Returns setItems wrapped so that every list it sets keeps only the items filed under categoryId, or setItems as it is without one. A list of one category's dumps or playlists passes it to the hooks that apply the socket's messages, so that one created outside the category isn't added, and one edited out of it leaves.

Usage

import * as mod from "src/hooks/category/useCategoryFilter.ts";