React to preplot_lines notifications

This commit is contained in:
D. Berge
2020-10-02 00:41:16 +02:00
parent 746e3405fb
commit f30f108e08

View File

@@ -137,12 +137,13 @@ export default {
num_lines: null,
sequences: [],
activeItem: null,
edit: null // {line, key, value}
edit: null, // {line, key, value}
queuedReload: false
}
},
computed: {
...mapGetters(['loading'])
...mapGetters(['loading', 'serverEvent'])
},
watch: {
@@ -164,6 +165,20 @@ export default {
}
}
}
},
async serverEvent (event) {
if (event.channel == "preplot_lines" && event.payload.pid == this.$route.params.project) {
if (!this.loading && !this.queuedReload) {
// Do not force a non-cached response if refreshing as a result
// of an event notification. We will assume that the server has
// already had time to update the cache by the time our request
// gets back to it.
this.getLines();
} else {
this.queuedReload = true;
}
}
}
},
@@ -207,6 +222,7 @@ export default {
const url = `/project/${this.$route.params.project}/line`;
this.queuedReload = false;
this.items = await this.api([url]) || [];
},