chore: 🤖 use tracked properties instead of attributes

This commit is contained in:
Randall Morey committed 2021-06-14 17:08:48 -04:00
1 parent 242c3f6370
commit 75bb34f738
2 files changed
+7 -21

No files matched your search

+2 -3
View File
@@ -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;
@@ -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