Removes the last react-refresh disables by splitting exports instead: - contexts/language.ts: Language/Translations types + LanguageContext + useTranslation/useT (LanguageProvider stays a component-only file); 12 importers repointed. - lib/sortOptions.ts: calculatePopularity + calculateDistance (out of SortDropdown) - lib/trustFilter.ts: TrustFilterLevel + filterByTrustLevel (out of TrustFilter) - EventCountdown: deleted the unused useEventStatus hook - NewsletterPage: dropped the NEWSLETTER_ISSUES re-export shim - AGENTS.md updated (lint stays clean with no blanket disables) Gate: 101 tests, 0 errors/warnings, boot smoke green.
34 lines
961 B
TypeScript
34 lines
961 B
TypeScript
/**
|
|
* Trust-filter levels + filtering helper. Kept out of TrustFilter.tsx so that
|
|
* component file exports only a component (React Fast Refresh).
|
|
*/
|
|
|
|
export type TrustFilterLevel = 'all' | 'verified' | 'trusted' | 'following';
|
|
|
|
/**
|
|
* Filter items by the web-of-trust score of their author.
|
|
* `verified` ≥ 90, `trusted` ≥ 60, `following` is the top of the source's graph.
|
|
*/
|
|
export function filterByTrustLevel<T extends { pubkey: string }>(
|
|
items: T[],
|
|
level: TrustFilterLevel,
|
|
getTrustScore: (pubkey: string) => number | undefined,
|
|
): T[] {
|
|
if (level === 'all') return items;
|
|
|
|
return items.filter((item) => {
|
|
const score = getTrustScore(item.pubkey);
|
|
if (score === undefined) return false;
|
|
|
|
switch (level) {
|
|
case 'verified':
|
|
return score >= 90;
|
|
case 'trusted':
|
|
return score >= 60;
|
|
case 'following':
|
|
return score === 90 || score === 100;
|
|
default:
|
|
return true;
|
|
}
|
|
});
|
|
}
|