refactor(chronik): replace inline filter switch with filterFeed()
Some checks failed
CI / Unit & Component Tests (push) Failing after 2m33s
CI / OCR Service Tests (push) Successful in 31s
CI / Backend Unit Tests (push) Failing after 2m49s
CI / Unit & Component Tests (pull_request) Failing after 2m37s
CI / OCR Service Tests (pull_request) Successful in 32s
CI / Backend Unit Tests (pull_request) Failing after 2m52s
Some checks failed
CI / Unit & Component Tests (push) Failing after 2m33s
CI / OCR Service Tests (push) Successful in 31s
CI / Backend Unit Tests (push) Failing after 2m49s
CI / Unit & Component Tests (pull_request) Failing after 2m37s
CI / OCR Service Tests (pull_request) Successful in 32s
CI / Backend Unit Tests (pull_request) Failing after 2m52s
Wire the extracted filterFeed function into the displayFeed derived, removing 20 lines of inline switch logic from +page.svelte. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@ import ChronikEmptyState from '$lib/components/chronik/ChronikEmptyState.svelte'
|
||||
import ChronikErrorCard from '$lib/components/chronik/ChronikErrorCard.svelte';
|
||||
import type { components } from '$lib/generated/api';
|
||||
import type { FilterValue } from './+page.server';
|
||||
import { filterFeed } from './feedFilters';
|
||||
|
||||
type ActivityFeedItemDTO = components['schemas']['ActivityFeedItemDTO'];
|
||||
|
||||
@@ -92,28 +93,7 @@ async function onMarkAllRead() {
|
||||
await notificationStore.markAllRead();
|
||||
}
|
||||
|
||||
const displayFeed = $derived<ActivityFeedItemDTO[]>(
|
||||
(() => {
|
||||
const merged = data.activityFeed;
|
||||
switch (activeFilter) {
|
||||
case 'alle':
|
||||
return merged;
|
||||
case 'fuer-dich':
|
||||
return merged.filter((i) => i.kind === 'MENTION_CREATED' || i.youMentioned);
|
||||
case 'hochgeladen':
|
||||
return merged.filter((i) => i.kind === 'FILE_UPLOADED');
|
||||
case 'transkription':
|
||||
return merged.filter(
|
||||
(i) =>
|
||||
i.kind === 'TEXT_SAVED' ||
|
||||
i.kind === 'BLOCK_REVIEWED' ||
|
||||
i.kind === 'ANNOTATION_CREATED'
|
||||
);
|
||||
case 'kommentare':
|
||||
return merged.filter((i) => i.kind === 'COMMENT_ADDED' || i.kind === 'MENTION_CREATED');
|
||||
}
|
||||
})()
|
||||
);
|
||||
const displayFeed = $derived(filterFeed(data.activityFeed, activeFilter));
|
||||
|
||||
const isEmpty = $derived(displayFeed.length === 0);
|
||||
const emptyVariant = $derived<'first-run' | 'filter-empty' | 'inbox-zero'>(
|
||||
|
||||
Reference in New Issue
Block a user