From f30f108e0867f34194ad4019b83a9f6048aba39e Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Fri, 2 Oct 2020 00:41:16 +0200 Subject: [PATCH] React to `preplot_lines` notifications --- lib/www/client/source/src/views/LineList.vue | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/www/client/source/src/views/LineList.vue b/lib/www/client/source/src/views/LineList.vue index 887dfdc..373f68d 100644 --- a/lib/www/client/source/src/views/LineList.vue +++ b/lib/www/client/source/src/views/LineList.vue @@ -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]) || []; },