Skip to content

Commit

Permalink
fix: better handling of new filters
Browse files Browse the repository at this point in the history
  • Loading branch information
jakowenko committed Sep 20, 2021
1 parent 19215ad commit 3fffa6e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
17 changes: 8 additions & 9 deletions frontend/src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -375,15 +375,14 @@ export default {
watch: {
dropdowns: {
handler(value) {
this.selected.names = this.selected.names
? this.selected.names.flatMap((item) => (value.names.includes(item) ? item : []))
: value.names;
this.selected.detectors = this.selected.detectors
? this.selected.detectors.flatMap((item) => (value.detectors.includes(item) ? item : []))
: value.detectors;
this.selected.matches = this.selected.matches
? this.selected.matches.flatMap((item) => (value.matches.includes(item) ? item : []))
: value.matches;
['names', 'detectors', 'matches'].forEach((key) => {
this.selected[key] =
JSON.stringify(
this.selected[key] ? this.selected[key].flatMap((item) => (value[key].includes(item) ? item : [])) : [],
) !== JSON.stringify(value[key])
? value[key]
: this.selected[key];
});
if (!this.selected.names.length && !this.selected.detectors.length && !this.selected.matches.length) {
this.selected.names = value.names;
Expand Down
15 changes: 10 additions & 5 deletions frontend/src/views/Match.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ export default {
},
folders: [],
loading: {
folders: true,
files: true,
folders: false,
files: false,
createFolder: false,
filter: false,
},
matches: {
source: [],
Expand Down Expand Up @@ -124,9 +125,11 @@ export default {
this.socket.off('recognize');
},
created() {
this.emitter.on('updateFilter', () => {
this.emitter.on('updateFilter', async () => {
this.clear(['source', 'selected', 'disabled', 'loaded']);
this.get().matches();
this.loading.filter = true;
await this.get().matches();
this.loading.filter = false;
});
this.emitter.on('trainingFolder', (value) => {
this.trainingFolder = value;
Expand Down Expand Up @@ -154,9 +157,11 @@ export default {
return {
async matches(delay = 0) {
try {
if ($this.loading.files) return;
$this.loading.files = true;
await Sleep(delay);
await $this.get().filters();
if (!$this.loading.filter) await $this.get().filters();
$this.filters = $this.$refs?.header?.getFilters() || {};
const sinceId =
// eslint-disable-next-line no-nested-ternary
Expand Down

0 comments on commit 3fffa6e

Please sign in to comment.