Skip to content

Commit

Permalink
fix: don't reset filters when all results on page are deleted (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakowenko committed Sep 24, 2021
1 parent 13ac384 commit bf5ebac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ export default {
};
},
refresh() {
if (this.type === 'match') this.$parent.get().matches(500);
if (this.type === 'match') this.$parent.get().matches({ delay: 500 });
if (this.type === 'train') this.$parent.init();
},
addComma(length, index) {
Expand Down
13 changes: 6 additions & 7 deletions frontend/src/views/Match.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ export default {
created() {
this.emitter.on('updateFilter', async () => {
this.clear(['source', 'selected', 'disabled', 'loaded']);
this.loading.filter = true;
await this.get().matches();
this.loading.filter = false;
await this.get().matches({ filters: false });
});
this.emitter.on('trainingFolder', (value) => {
this.trainingFolder = value;
Expand All @@ -164,13 +162,14 @@ export default {
get() {
const $this = this;
return {
async matches(delay = 0) {
async matches(options) {
try {
const { filters = true, delay = 0 } = options || {};
if ($this.loading.files) return;
$this.loading.files = true;
await Sleep(delay);
if (!$this.loading.filter) await $this.get().filters();
if (filters) await $this.get().filters();
$this.filters = $this.$refs?.header?.getFilters() || {};
const sinceId =
// eslint-disable-next-line no-nested-ternary
Expand Down Expand Up @@ -200,7 +199,7 @@ export default {
if ($this.pagination.temp > 1 && !data.matches.length) {
$this.pagination.temp -= 1;
await $this.get().matches();
await $this.get().matches({ filters: false });
}
} catch (error) {
$this.loading.files = false;
Expand Down Expand Up @@ -239,7 +238,7 @@ export default {
$this.emitter.emit('toast', { message: `${description} deleted` });
if (areAllSelected) {
$this.clear(['source', 'selected', 'disabled', 'loaded']);
await $this.get().matches();
await $this.get().matches({ filters: false });
}
} catch (error) {
$this.emitter.emit('error', error);
Expand Down

0 comments on commit bf5ebac

Please sign in to comment.