✨ Implement logic to display unique files by type, prioritizing the largest file for each type
This commit is contained in:
@@ -95,7 +95,7 @@
|
||||
<select id="file-select" v-model="selectedFile" @change="onFileChange">
|
||||
<option value="">-- Choose a file --</option>
|
||||
<option
|
||||
v-for="file in status.available"
|
||||
v-for="file in uniqueFiles"
|
||||
:key="file.filename"
|
||||
:value="getFileType(file.filename)"
|
||||
>
|
||||
@@ -408,6 +408,29 @@ const highlightConfig = computed(() => ({
|
||||
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
|
||||
function getHighlightedContent(lineContent) {
|
||||
if (!searchQuery.value.trim()) return lineContent;
|
||||
|
||||
Reference in New Issue
Block a user