import type { components } from '$lib/generated/api';
import type { FilterValue } from './+page.server';

type ActivityFeedItemDTO = components['schemas']['ActivityFeedItemDTO'];

// All server-side filters (hochgeladen, transkription, kommentare) are already applied via
// kinds param — the server returns only matching items, so client-side is a no-op.
// fuer-dich is the only filter that requires client-side narrowing: youMentioned and
// youParticipated are user-scoped flags that cannot be expressed as a kinds filter.
export function applyClientFilter(
	items: ActivityFeedItemDTO[],
	filter: FilterValue
): ActivityFeedItemDTO[] {
	if (filter === 'fuer-dich') {
		return items.filter((item) => item.youMentioned || item.youParticipated);
	}
	return items;
}
