From 81ad3575db3cc6a70a3ace9bf6f23de998237b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 12 Apr 2022 17:27:16 +0200 Subject: [PATCH] Web: only fetch selected job if not yet fully known --- web/app/src/App.vue | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/web/app/src/App.vue b/web/app/src/App.vue index 2c9af4aa..32b84112 100644 --- a/web/app/src/App.vue +++ b/web/app/src/App.vue @@ -54,10 +54,23 @@ export default { methods: { // UI component event handlers: onSelectedJobChanged(jobSummary) { + const fullJob = API.Job.constructFromObject(jobSummary); + if (fullJob.created) { + // The 'created' field is not part of the JobUpdate, but it is part of + // Job, so if that field is there, we can assume that this is an + // already-fetched job. + // TODO: keep track of when this was fetched, and re-fetch if necessary. + this.selectedJob = fullJob; + return; + } + const jobsAPI = new API.JobsApi(this.apiClient); this._wrap(jobsAPI.fetchJob(jobSummary.id)) .then((job) => { this.selectedJob = job; + // Forward the full job to Tabulator, so that the next selection + // doesn't have to re-fetch it. + this.$refs.jobsTable.processJobUpdate(job); }); }, sendMessage(message) {