🎨 Improve code readability by reformatting imports, refining filter and sort logic, and simplifying function syntax
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch } from 'vue';
|
||||||
import { perfMonitor } from '@/utilities/performance-utils.js';
|
import { perfMonitor } from '@/utilities/performance-utils.js';
|
||||||
import { extractJsonPaths, extractJsonPathsLazy } from '@/utilities/json-utils.js';
|
import {
|
||||||
|
extractJsonPaths,
|
||||||
|
extractJsonPathsLazy
|
||||||
|
} from '@/utilities/json-utils.js';
|
||||||
import { useLocalStorage } from '@/composables/useLocalStorage.js';
|
import { useLocalStorage } from '@/composables/useLocalStorage.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,12 +58,14 @@ export function useGamemasterFiles(client) {
|
|||||||
const seen = new Set();
|
const seen = new Set();
|
||||||
const order = { pokemon: 1, allForms: 2, moves: 3, raw: 4 };
|
const order = { pokemon: 1, allForms: 2, moves: 3, raw: 4 };
|
||||||
|
|
||||||
return availableFiles.value.filter(file => {
|
return availableFiles.value
|
||||||
|
.filter(file => {
|
||||||
const type = getFileType(file.filename);
|
const type = getFileType(file.filename);
|
||||||
if (seen.has(type)) return false;
|
if (seen.has(type)) return false;
|
||||||
seen.add(type);
|
seen.add(type);
|
||||||
return true;
|
return true;
|
||||||
}).sort((a, b) => {
|
})
|
||||||
|
.sort((a, b) => {
|
||||||
const typeA = getFileType(a.filename);
|
const typeA = getFileType(a.filename);
|
||||||
const typeB = getFileType(b.filename);
|
const typeB = getFileType(b.filename);
|
||||||
return (order[typeA] ?? 999) - (order[typeB] ?? 999);
|
return (order[typeA] ?? 999) - (order[typeB] ?? 999);
|
||||||
@@ -244,17 +249,14 @@ export function useGamemasterFiles(client) {
|
|||||||
return; // Already visible
|
return; // Already visible
|
||||||
}
|
}
|
||||||
|
|
||||||
const newEndIndex = Math.min(
|
const newEndIndex = Math.min(lineNumber + 1000, fileLines.value.length);
|
||||||
lineNumber + 1000,
|
|
||||||
fileLines.value.length
|
|
||||||
);
|
|
||||||
updateDisplayLines(0, newEndIndex);
|
updateDisplayLines(0, newEndIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Watch for file selection changes
|
* Watch for file selection changes
|
||||||
*/
|
*/
|
||||||
watch(selectedFile, async (newFile) => {
|
watch(selectedFile, async newFile => {
|
||||||
if (newFile) {
|
if (newFile) {
|
||||||
await loadFile();
|
await loadFile();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user