Implement logic to display unique files by type, prioritizing the largest file for each type

This commit is contained in:
2026-01-28 20:27:59 +00:00
parent 469bbb186d
commit 1b9a1d9386

View File

@@ -95,7 +95,7 @@
<select id="file-select" v-model="selectedFile" @change="onFileChange"> <select id="file-select" v-model="selectedFile" @change="onFileChange">
<option value="">-- Choose a file --</option> <option value="">-- Choose a file --</option>
<option <option
v-for="file in status.available" v-for="file in uniqueFiles"
:key="file.filename" :key="file.filename"
:value="getFileType(file.filename)" :value="getFileType(file.filename)"
> >
@@ -408,6 +408,29 @@ const highlightConfig = computed(() => ({
language: 'json' language: 'json'
})); }));
// Get unique files by type (only show one of each file type, prefer largest)
const uniqueFiles = computed(() => {
const fileMap = new Map();
status.value.available?.forEach(file => {
const fileType = getFileType(file.filename);
const existing = fileMap.get(fileType);
// Keep the largest file of each type
if (!existing || file.size > existing.size) {
fileMap.set(fileType, file);
}
});
// Return files in consistent order
return Array.from(fileMap.values()).sort((a, b) => {
const order = { pokemon: 0, allForms: 1, moves: 2, raw: 3 };
const typeA = getFileType(a.filename);
const typeB = getFileType(b.filename);
return (order[typeA] ?? 999) - (order[typeB] ?? 999);
});
});
// Helper to get highlighted content for search results // Helper to get highlighted content for search results
function getHighlightedContent(lineContent) { function getHighlightedContent(lineContent) {
if (!searchQuery.value.trim()) return lineContent; if (!searchQuery.value.trim()) return lineContent;