@@ -22,6 +22,7 @@ export default function MemorialIndexPage() { |
| 22 | 22 | const [error, setError] = useState<string | null>(null); |
| 23 | 23 | const [expandedConflicts, setExpandedConflicts] = useState<Set<number>>(new Set()); |
| 24 | 24 | const [sortBy, setSortBy] = useState<'alphabetical' | 'class_year'>('alphabetical'); |
| 25 | + const [isInitialLoad, setIsInitialLoad] = useState(true); |
| 25 | 26 | |
| 26 | 27 | useEffect(() => { |
| 27 | 28 | async function fetchData() { |
@@ -37,11 +38,12 @@ export default function MemorialIndexPage() { |
| 37 | 38 | setConflicts(data); |
| 38 | 39 | |
| 39 | 40 | // By default, expand conflicts with casualties (only on first load) |
| 40 | | - if (expandedConflicts.size === 0) { |
| 41 | + if (isInitialLoad) { |
| 41 | 42 | const defaultExpanded = new Set<number>( |
| 42 | 43 | data.filter((c: ConflictWithCasualties) => c.casualty_count > 0).map((c: ConflictWithCasualties) => c.id) |
| 43 | 44 | ); |
| 44 | 45 | setExpandedConflicts(defaultExpanded); |
| 46 | + setIsInitialLoad(false); |
| 45 | 47 | } |
| 46 | 48 | } catch (err) { |
| 47 | 49 | setError(err instanceof Error ? err.message : 'Failed to load data'); |
@@ -52,7 +54,7 @@ export default function MemorialIndexPage() { |
| 52 | 54 | } |
| 53 | 55 | |
| 54 | 56 | fetchData(); |
| 55 | | - }, [sortBy]); |
| 57 | + }, [sortBy, isInitialLoad]); |
| 56 | 58 | |
| 57 | 59 | const toggleConflict = (conflictId: number) => { |
| 58 | 60 | const newExpanded = new Set(expandedConflicts); |
@@ -157,7 +159,7 @@ export default function MemorialIndexPage() { |
| 157 | 159 | : 'text-gray-500' |
| 158 | 160 | }`} |
| 159 | 161 | > |
| 160 | | - '42 |
| 162 | + '42 |
| 161 | 163 | </span> |
| 162 | 164 | </button> |
| 163 | 165 | </div> |
@@ -211,7 +213,7 @@ export default function MemorialIndexPage() { |
| 211 | 213 | ? person.display_name.replace(person.rank + ' ', '').replace(person.rank + ', ', '') |
| 212 | 214 | : person.display_name} |
| 213 | 215 | {person.class_year && ( |
| 214 | | - <span className="text-gray-600 font-normal">'{String(person.class_year).slice(-2)}</span> |
| 216 | + <span className="text-gray-600 font-normal">'{String(person.class_year).slice(-2)}</span> |
| 215 | 217 | )} |
| 216 | 218 | {person.pdf_key && <DocumentIcon className="flex-shrink-0" />} |
| 217 | 219 | </h3> |