Added a "Hide all visible" button

It hides the opportunities the filters show that aren't hidden already,
after asking for confirmation with their count. Those the filters leave
out keep their marks, so clearing the filters shows them as before.

The backend has no bulk route, so each opportunity is hidden with its
own request. The rows go at once; every mark change is now saved at
most six at a time (lib/concurrency.ts), so hundreds of requests aren't
sent together. Any that fail are shown again, with one toast for them
all.
This commit is contained in:
bwilliams committed 2026-10-19 09:47:49 +01:00
1 parent b1cc9745ba
commit b8244da2e5
7 files changed
+205 -10

No files matched your search

+17
View File
@@ -8,6 +8,7 @@ import { ThemeToggle } from '@/components/ThemeToggle';
import { ToastList } from '@/components/ToastList';
import type { OpportunityFilters } from '@/lib/filterOpportunities';
import { emptyFilters, filterOpportunities, statusOptions } from '@/lib/filterOpportunities';
import { formatCount } from '@/lib/format';
import { createLiveUpdates } from '@/primitives/createLiveUpdates';
import { createClassifications, createOpportunities } from '@/primitives/createOpportunities';
import { createOpportunityAnnotations } from '@/primitives/createOpportunityAnnotations';
@@ -35,6 +36,20 @@ export function App(): JSX.Element {
setFilters(emptyFilters());
};
// Only the rows shown are hidden: those a filter leaves out keep their
// marks, and come back as they were when it's cleared.
const hideable = createMemo(() =>
rows()
.map((opportunity) => opportunity.uuid)
.filter((uuid) => !annotations.get(uuid).hidden),
);
const hideAllVisible = (): void => {
const uuids = hideable();
const count =
uuids.length === 1 ? 'this opportunity' : `these ${formatCount(uuids.length)} opportunities`;
if (window.confirm(`Hide ${count}?`)) annotations.hideAll(uuids);
};
// A failed load is shown where the list would be, with a retry, and as a
// toast, so it's seen wherever the user is looking.
createEffect(() => {
@@ -64,6 +79,8 @@ export function App(): JSX.Element {
onRetryClassifications={classifications.reload}
shown={rows().length}
total={opportunities.items().length}
hideable={hideable().length}
onHideAll={hideAllVisible}
/>
<main>