From ee6d0324928adee6e0763e2a02387818878bc431 Mon Sep 17 00:00:00 2001 From: mrmeku Date: Thu, 18 Apr 2019 13:47:55 -0600 Subject: [PATCH] fix(settings): Use observable for disable animations toggle (#656) --- apps/angular-console-e2e/src/support/tasks.utils.ts | 4 ++-- apps/angular-console/src/app/app.component.html | 2 +- libs/utils/src/lib/settings.service.ts | 10 +++++++++- tslint.json | 2 ++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/angular-console-e2e/src/support/tasks.utils.ts b/apps/angular-console-e2e/src/support/tasks.utils.ts index 063607b98e..47c9de1b08 100644 --- a/apps/angular-console-e2e/src/support/tasks.utils.ts +++ b/apps/angular-console-e2e/src/support/tasks.utils.ts @@ -25,7 +25,7 @@ export function checkActionBarHidden() { export function checkSingleRecentTask(task: Task) { cy.get('angular-console-action-bar mat-list-item').should(tasks => { expect(tasks.length).to.equal(1); - expect(tasks).visible; + expect(tasks).visible(); expect( tasks @@ -34,7 +34,7 @@ export function checkSingleRecentTask(task: Task) { .textContent!.trim() ).to.equal(task.command); - expect(tasks.find(`.task-avatar.${task.status}`)).visible; + expect(tasks.find(`.task-avatar.${task.status}`)).visible(); }); } diff --git a/apps/angular-console/src/app/app.component.html b/apps/angular-console/src/app/app.component.html index c90c036ab8..142f7e5257 100644 --- a/apps/angular-console/src/app/app.component.html +++ b/apps/angular-console/src/app/app.component.html @@ -2,7 +2,7 @@ fxLayout="column" fxFlex class="content-container" - [@.disabled]="settings.useDisableAnimations()" + [@.disabled]="settings.disabledAnimations$ | async" > diff --git a/libs/utils/src/lib/settings.service.ts b/libs/utils/src/lib/settings.service.ts index da679d3be4..3911884d64 100644 --- a/libs/utils/src/lib/settings.service.ts +++ b/libs/utils/src/lib/settings.service.ts @@ -4,8 +4,10 @@ import { first, tap } from 'rxjs/operators'; import { Settings as SettingsModels, SettingsGQL, - UpdateSettingsGQL + UpdateSettingsGQL, + Maybe } from './generated/graphql'; +import { BehaviorSubject } from 'rxjs'; export { Settings as SettingsModels } from './generated/graphql'; @@ -109,8 +111,14 @@ export class Settings { return this.settings.channel; } + private readonly disabledAnimationsSubject = new BehaviorSubject< + Maybe + >(this.settings.disableAnimations); + readonly disabledAnimations$ = this.disabledAnimationsSubject.asObservable(); + setDisableAnimations(disableAnimations: boolean): void { this.store({ ...this.settings, disableAnimations }); + this.disabledAnimationsSubject.next(disableAnimations); } useDisableAnimations() { diff --git a/tslint.json b/tslint.json index b749a25af9..65ef894e57 100644 --- a/tslint.json +++ b/tslint.json @@ -47,6 +47,8 @@ "no-attribute-parameter-decorator": true, "no-output-named-after-standard-event": true, "no-forward-ref": true, + "no-unused-variable": true, + "no-unused-expression": true, "no-unused-css": false, "contextual-life-cycle": true, "trackBy-function": false,