From 75bb34f738fb76bf4d5a262aabc2791e49c02cdb Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Mon, 14 Jun 2021 17:08:48 -0400 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20use=20tracked=20propert?= =?UTF-8?q?ies=20instead=20of=20attributes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/api/addon/models/session.js | 5 ++-- .../routes/scopes/scope/projects/targets.js | 23 ++++--------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/addons/api/addon/models/session.js b/addons/api/addon/models/session.js index f85593958..8c81b8a5a 100644 --- a/addons/api/addon/models/session.js +++ b/addons/api/addon/models/session.js @@ -1,7 +1,6 @@ import GeneratedSessionModel from '../generated/models/session'; import { computed } from '@ember/object'; import { equal } from '@ember/object/computed'; -import { attr } from '@ember-data/model'; import { tracked } from '@glimmer/tracking'; export default class SessionModel extends GeneratedSessionModel { @@ -9,8 +8,8 @@ export default class SessionModel extends GeneratedSessionModel { @tracked acknowledged; @tracked started_desktop_client; - @attr('string', { readOnly: true }) proxy_address; - @attr('number', { readOnly: true }) proxy_port; + @tracked proxy_address; + @tracked proxy_port; @equal('status', 'active') isActive; @equal('status', 'pending') isPending; diff --git a/ui/desktop/app/routes/scopes/scope/projects/targets.js b/ui/desktop/app/routes/scopes/scope/projects/targets.js index 3b847e020..87773dc2b 100644 --- a/ui/desktop/app/routes/scopes/scope/projects/targets.js +++ b/ui/desktop/app/routes/scopes/scope/projects/targets.js @@ -2,7 +2,6 @@ import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import { task, timeout } from 'ember-concurrency'; -import { later } from '@ember/runloop'; import config from '../../../../config/environment'; const POLL_TIMEOUT_SECONDS = config.sessionPollingTimeoutSeconds; @@ -112,26 +111,14 @@ export default class ScopesScopeProjectsTargetsRoute extends Route { // Associate the connection details with the session const { session_id, address, port } = connectionDetails; const session = await this.store.findRecord('session', session_id); + // Flag the session has been open in the desktop client session.started_desktop_client = true; - // Update the session record with proxy information from the CLI - // This is read-only information that shouldn't dirty the session, - // so we use store.push here. In the future, it may make sense to push - // this off to the API so that we don't have to manually persist the - // proxy details. - later(() => { - this.store.push({ - data: { - id: session_id, - type: 'session', - attributes: { - proxy_address: address, - proxy_port: port - } - } - }); - }, 150); + // In the future, it may make sense to push this off to the API so that + // we don't have to manually persist the proxy details. + session.proxy_address = address; + session.proxy_port = port; } catch(e) { this.confirm.confirm(e.message, { isConnectError: true }) // Retry