Skip to content

Commit

Permalink
don't overwrite selected files with new upload
Browse files Browse the repository at this point in the history
  • Loading branch information
gamcil committed Aug 14, 2024
1 parent f692854 commit 8e025ac
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion frontend/FoldMasonSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ export default {
alignDisabled() {
return this.queries.length <= 1 || this.inSearch;
},
fileNameSet() {
return new Set(this.queries.map(f => f.name));
}
},
watch: {
},
Expand Down Expand Up @@ -260,6 +263,13 @@ export default {
async removeQuery(index) {
this.queries.splice(index, 1);
},
async addFiles(newFiles) {
for (const newFile of newFiles) {
if (!this.fileNameSet.has(newFile.name)) {
this.queries.push(newFile);
}
}
},
/**
* Load all files and add them to component state
* TODOs:
Expand All @@ -279,7 +289,7 @@ export default {
try {
const fileReadPromises = Array.from(files).map(readFile);
const fileContents = await Promise.all(fileReadPromises);
this.queries = fileContents;
this.addFiles(fileContents);
} catch(error) {
console.log("Error reading files", error);
}
Expand Down

0 comments on commit 8e025ac

Please sign in to comment.