From 837d75f733ce6180c98adc67ce6114823708232c Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Fri, 26 Feb 2021 17:07:29 -0500 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20poll=20for=20targets=20?= =?UTF-8?q?too,=20so=20desktop=20views=20are=20"live"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../routes/scopes/scope/projects/targets.js | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/ui/desktop/app/routes/scopes/scope/projects/targets.js b/ui/desktop/app/routes/scopes/scope/projects/targets.js index f16ccb61e..63884e634 100644 --- a/ui/desktop/app/routes/scopes/scope/projects/targets.js +++ b/ui/desktop/app/routes/scopes/scope/projects/targets.js @@ -32,7 +32,7 @@ export default class ScopesScopeProjectsTargetsRoute extends Route { @task(function * () { while(true) { yield timeout(POLL_TIMEOUT_SECONDS * 1000); - yield this.refreshSessions(); + yield this.refresh(); } }).drop() poller; @@ -51,7 +51,12 @@ export default class ScopesScopeProjectsTargetsRoute extends Route { */ async model() { const { id: scope_id } = this.modelFor('scopes.scope'); - await this.refreshSessions(); + const { user_id } = this.session.data.authenticated; + await this.store.query('session', { + filter: `"/item/user_id" == "${user_id}"`, + recursive: true, + scope_id + }); return this.store.query('target', { filter: '"authorize-session" in "/item/authorized_actions"', recursive: true, @@ -59,16 +64,6 @@ export default class ScopesScopeProjectsTargetsRoute extends Route { }); } - /** - * Loads all sessions for all scopes in order to prime the store. - * Targets peek into the store to determine if they are active. - * TODO: query only for sessions associated with the current user. - */ - async refreshSessions() { - const { id: scope_id } = this.modelFor('scopes.scope'); - await this.store.query('session', { recursive: true, scope_id }); - } - /** * When this route is activated (entered), begin polling for changes. */ @@ -92,7 +87,7 @@ export default class ScopesScopeProjectsTargetsRoute extends Route { */ @action async connect(model, host) { - // TODO: Connect: Refactor into an addon + // TODO: Connect: move this logic into the target model try { // Check for CLI const cliExists = await this.ipc.invoke('cliExists');