import { useState, useMemo } from 'react'; import { Link } from 'react-router-dom'; import { useForum } from '@/contexts/useForum'; import { Layout, MessageSquare, RefreshCw, Loader2, TrendingUp, Clock, } from 'lucide-react'; import { CreateCellDialog } from './CreateCellDialog'; import { Button } from '@/components/ui/button'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select'; import { CypherImage } from './ui/CypherImage'; import { RelevanceIndicator } from './ui/relevance-indicator'; import { sortCells, SortOption } from '@/lib/forum/sorting'; const CellList = () => { const { cells, isInitialLoading, posts, refreshData, isRefreshing } = useForum(); const [sortOption, setSortOption] = useState('relevance'); // Apply sorting to cells const sortedCells = useMemo(() => { return sortCells(cells, sortOption); }, [cells, sortOption]); if (isInitialLoading) { return (

Loading Cells...

Connecting to the network and fetching data...

); } const getPostCount = (cellId: string) => { return posts.filter(post => post.cellId === cellId).length; }; return (

Cells

{cells.length === 0 ? (
No cells found. Be the first to create one!
) : ( sortedCells.map(cell => (

{cell.name}

{cell.description}

{getPostCount(cell.id)} threads
{cell.relevanceScore !== undefined && ( )}
)) )}
); }; export default CellList;