Files
eranos/src/lib/feedFilterUtils.ts
T
Chad Curtis 0c29506402 Fix all 50 ESLint warnings by extracting non-component exports and adding missing deps
- Extract utility functions from component files into dedicated modules
  to fix react-refresh/only-export-components warnings:
  - parseBadgeDefinition -> src/lib/parseBadgeDefinition.ts
  - parseProfileBadges -> src/lib/parseProfileBadges.ts
  - getColors, paletteToTheme -> src/lib/colorMomentUtils.ts
  - parseDimToAspectRatio, eventToMediaItem -> src/lib/mediaUtils.ts
  - isAudioUrl, isImageUrl, isVideoUrl -> src/lib/mediaTypeDetection.ts
  - buildKindOptions, parseSelectedKinds -> src/lib/feedFilterUtils.ts
  - useVideoThumbnail -> src/hooks/useVideoThumbnail.ts
  - useEnvelopeDimensions -> src/hooks/useEnvelopeDimensions.ts
  - usePortalContainer -> src/hooks/usePortalContainer.ts
  - useAudioPlayer -> src/contexts/audioPlayerContextDef.ts
  - SubHeaderBar context/hooks -> src/components/SubHeaderBarContext.ts
  - EmotionDev hooks -> src/blobbi/dev/useEmotionDev.ts
  - BlobbiActions context def -> BlobbiActionsContextDef.ts

- Remove export from internal-only functions (useEventComments,
  parseEmojiPack, useScrollCarets, formatEffectSummary, getSortedEffectEntries)

- Fix react-hooks/exhaustive-deps warnings by adding missing dependencies
  to useEffect/useCallback/useMemo hooks across 14 files

- Fix logical expression dependency warnings by wrapping conditional
  values (tasks, pubkeys, authorPubkeys) in useMemo

- Move module-level constants (CORE_TAB_IDS, CORE_TAB_LABELS,
  DEFAULT_TAB_LABELS) out of ProfilePage component body

- Reorder usePushNotifications hooks so syncPreferences is defined
  before enable to fix block-scoped variable error
2026-04-05 11:57:31 -05:00

51 lines
1.4 KiB
TypeScript

import { EXTRA_KINDS } from '@/lib/extraKinds';
import { CONTENT_KIND_ICONS } from '@/lib/sidebarItems';
import type { TabFilter } from '@/contexts/AppContext';
type KindOption = {
value: string;
label: string;
description: string;
parentId: string;
icon: React.ComponentType<{ className?: string }> | undefined;
};
/** Build the kind options from EXTRA_KINDS definitions. */
export function buildKindOptions(): KindOption[] {
const options: KindOption[] = [];
for (const def of EXTRA_KINDS) {
if (def.subKinds) {
for (const sub of def.subKinds) {
options.push({
value: String(sub.kind),
label: `${sub.label} (${sub.kind})`,
description: sub.description,
parentId: def.id,
icon: CONTENT_KIND_ICONS[def.id],
});
}
} else {
options.push({
value: String(def.kind),
label: `${def.label} (${def.kind})`,
description: def.description,
parentId: def.id,
icon: CONTENT_KIND_ICONS[def.id],
});
}
}
const seen = new Set<string>();
return options.filter((o) => {
if (seen.has(o.value)) return false;
seen.add(o.value);
return true;
});
}
/** Parse a TabFilter's kinds array into an array of string kind values. */
export function parseSelectedKinds(filter: TabFilter): string[] {
const kinds = filter.kinds;
if (!Array.isArray(kinds) || kinds.length === 0) return [];
return kinds.map(String);
}