Various Fixes and QoL enhancements.

This commit is contained in:
Stefan Hardegger
2025-07-26 12:05:54 +02:00
parent 5e8164c6a4
commit f95d7aa8bb
32 changed files with 758 additions and 136 deletions

View File

@@ -26,19 +26,27 @@ export default function CollectionsPage() {
const [totalCollections, setTotalCollections] = useState(0);
const [refreshTrigger, setRefreshTrigger] = useState(0);
// Load tags for filtering
useEffect(() => {
const loadTags = async () => {
try {
const tagsResult = await tagApi.getTags({ page: 0, size: 1000 });
setTags(tagsResult?.content || []);
} catch (error) {
console.error('Failed to load tags:', error);
}
};
// Extract tags from current collection results with counts
const extractTagsFromResults = (collections: Collection[]): Tag[] => {
const tagCounts: { [key: string]: number } = {};
loadTags();
}, []);
collections.forEach(collection => {
collection.tagNames?.forEach(tagName => {
if (tagCounts[tagName]) {
tagCounts[tagName]++;
} else {
tagCounts[tagName] = 1;
}
});
});
return Object.entries(tagCounts).map(([tagName, count]) => ({
id: tagName, // Use tag name as ID since we don't have actual IDs from search results
name: tagName,
collectionCount: count
}));
};
// Load collections with search and filters
useEffect(() => {
@@ -55,9 +63,14 @@ export default function CollectionsPage() {
archived: showArchived,
});
setCollections(result?.results || []);
const currentCollections = result?.results || [];
setCollections(currentCollections);
setTotalPages(Math.ceil((result?.totalHits || 0) / pageSize));
setTotalCollections(result?.totalHits || 0);
// Always update tags based on current search results (including initial wildcard search)
const resultTags = extractTagsFromResults(currentCollections);
setTags(resultTags);
} catch (error) {
console.error('Failed to load collections:', error);
setCollections([]);
@@ -223,6 +236,7 @@ export default function CollectionsPage() {
tags={tags}
selectedTags={selectedTags}
onTagToggle={handleTagToggle}
showCollectionCount={true}
/>
</div>