Skip to content

Commit

Permalink
fix(settings): Use observable for disable animations toggle (#656)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmeku authored Apr 18, 2019
1 parent 5b734a6 commit ee6d032
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions apps/angular-console-e2e/src/support/tasks.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
});
}

Expand Down
2 changes: 1 addition & 1 deletion apps/angular-console/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
fxLayout="column"
fxFlex
class="content-container"
[@.disabled]="settings.useDisableAnimations()"
[@.disabled]="settings.disabledAnimations$ | async"
>
<ui-contextual-action-bar></ui-contextual-action-bar>

Expand Down
10 changes: 9 additions & 1 deletion libs/utils/src/lib/settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -109,8 +111,14 @@ export class Settings {
return this.settings.channel;
}

private readonly disabledAnimationsSubject = new BehaviorSubject<
Maybe<boolean>
>(this.settings.disableAnimations);
readonly disabledAnimations$ = this.disabledAnimationsSubject.asObservable();

setDisableAnimations(disableAnimations: boolean): void {
this.store({ ...this.settings, disableAnimations });
this.disabledAnimationsSubject.next(disableAnimations);
}

useDisableAnimations() {
Expand Down
2 changes: 2 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ee6d032

Please sign in to comment.