From 21a5ae5024b20c922bfded985a3024cc2d4aed95 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Sun, 18 Nov 2018 20:11:11 +0100 Subject: [PATCH] Rx fixes. --- .../EventConsumers/EventConsumersController.cs | 2 +- .../event-consumers/event-consumers-page.component.ts | 2 +- .../pages/restore/restore-page.component.ts | 4 ++-- .../administration/state/event-consumers.state.spec.ts | 4 ++-- .../administration/state/event-consumers.state.ts | 2 +- .../content/pages/content/content-history.component.ts | 4 ++-- .../settings/pages/backups/backups-page.component.ts | 3 +-- src/Squidex/app/shared/components/comments.component.ts | 8 +++++--- src/Squidex/app/shared/components/history.component.ts | 4 ++-- 9 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/Squidex/Areas/Api/Controllers/EventConsumers/EventConsumersController.cs b/src/Squidex/Areas/Api/Controllers/EventConsumers/EventConsumersController.cs index 170ce80f4..1a7c459a7 100644 --- a/src/Squidex/Areas/Api/Controllers/EventConsumers/EventConsumersController.cs +++ b/src/Squidex/Areas/Api/Controllers/EventConsumers/EventConsumersController.cs @@ -35,7 +35,7 @@ namespace Squidex.Areas.Api.Controllers.EventConsumers { var entities = await eventConsumerManagerGrain.GetConsumersAsync(); - var response = entities.Value.Select(EventConsumerDto.FromEventConsumerInfo).ToList(); + var response = entities.Value.OrderBy(x => x.Name).Select(EventConsumerDto.FromEventConsumerInfo).ToList(); return Ok(response); } diff --git a/src/Squidex/app/features/administration/pages/event-consumers/event-consumers-page.component.ts b/src/Squidex/app/features/administration/pages/event-consumers/event-consumers-page.component.ts index a8df38179..fabccfead 100644 --- a/src/Squidex/app/features/administration/pages/event-consumers/event-consumers-page.component.ts +++ b/src/Squidex/app/features/administration/pages/event-consumers/event-consumers-page.component.ts @@ -38,7 +38,7 @@ export class EventConsumersPageComponent implements OnDestroy, OnInit { this.eventConsumersState.load(false, true).pipe(onErrorResumeNext()).subscribe(); this.timerSubscription = - timer(2000, 2000).pipe(switchMap(x => this.eventConsumersState.load(true, true)), onErrorResumeNext()) + timer(2000, 2000).pipe(switchMap(x => this.eventConsumersState.load(true, true).pipe(onErrorResumeNext()))) .subscribe(); } diff --git a/src/Squidex/app/features/administration/pages/restore/restore-page.component.ts b/src/Squidex/app/features/administration/pages/restore/restore-page.component.ts index 32884a7d2..026f0becb 100644 --- a/src/Squidex/app/features/administration/pages/restore/restore-page.component.ts +++ b/src/Squidex/app/features/administration/pages/restore/restore-page.component.ts @@ -8,7 +8,7 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { FormBuilder } from '@angular/forms'; import { Subscription, timer } from 'rxjs'; -import { filter, switchMap } from 'rxjs/operators'; +import { filter, onErrorResumeNext, switchMap } from 'rxjs/operators'; import { AuthService, @@ -43,7 +43,7 @@ export class RestorePageComponent implements OnDestroy, OnInit { public ngOnInit() { this.timerSubscription = - timer(0, 2000).pipe(switchMap(() => this.backupsService.getRestore()), filter(x => !!x)) + timer(0, 2000).pipe(switchMap(() => this.backupsService.getRestore().pipe(onErrorResumeNext())), filter(x => !!x)) .subscribe(dto => { this.restoreJob = dto!; }); diff --git a/src/Squidex/app/features/administration/state/event-consumers.state.spec.ts b/src/Squidex/app/features/administration/state/event-consumers.state.spec.ts index 45aa75468..bcf39a3e5 100644 --- a/src/Squidex/app/features/administration/state/event-consumers.state.spec.ts +++ b/src/Squidex/app/features/administration/state/event-consumers.state.spec.ts @@ -53,11 +53,11 @@ describe('EventConsumersState', () => { dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.once()); }); - it('should show notification on load error when silent is true', () => { + it('should show notification on load error when silent is false', () => { eventConsumersService.setup(x => x.getEventConsumers()) .returns(() => throwError({})); - eventConsumersState.load(true, true).pipe(onErrorResumeNext()).subscribe(); + eventConsumersState.load(true, false).pipe(onErrorResumeNext()).subscribe(); expect().nothing(); diff --git a/src/Squidex/app/features/administration/state/event-consumers.state.ts b/src/Squidex/app/features/administration/state/event-consumers.state.ts index ef14e7963..e98fd0cf8 100644 --- a/src/Squidex/app/features/administration/state/event-consumers.state.ts +++ b/src/Squidex/app/features/administration/state/event-consumers.state.ts @@ -59,7 +59,7 @@ export class EventConsumersState extends State { }); }), catchError(error => { - if (silent) { + if (!silent) { this.dialogs.notifyError(error); } diff --git a/src/Squidex/app/features/content/pages/content/content-history.component.ts b/src/Squidex/app/features/content/pages/content/content-history.component.ts index c323106d9..8bc250a91 100644 --- a/src/Squidex/app/features/content/pages/content/content-history.component.ts +++ b/src/Squidex/app/features/content/pages/content/content-history.component.ts @@ -8,7 +8,7 @@ import { Component } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { merge, Observable, timer } from 'rxjs'; -import { delay, switchMap } from 'rxjs/operators'; +import { delay, onErrorResumeNext, switchMap } from 'rxjs/operators'; import { allParams, @@ -51,7 +51,7 @@ export class ContentHistoryComponent { timer(0, 10000), this.messageBus.of(HistoryChannelUpdated).pipe(delay(1000)) ).pipe( - switchMap(() => this.historyService.getHistory(this.appsState.appName, this.channel))); + switchMap(() => this.historyService.getHistory(this.appsState.appName, this.channel).pipe(onErrorResumeNext()))); constructor( private readonly appsState: AppsState, diff --git a/src/Squidex/app/features/settings/pages/backups/backups-page.component.ts b/src/Squidex/app/features/settings/pages/backups/backups-page.component.ts index 825410d14..79b851195 100644 --- a/src/Squidex/app/features/settings/pages/backups/backups-page.component.ts +++ b/src/Squidex/app/features/settings/pages/backups/backups-page.component.ts @@ -37,8 +37,7 @@ export class BackupsPageComponent implements OnInit, OnDestroy { this.backupsState.load(false, true).pipe(onErrorResumeNext()).subscribe(); this.timerSubscription = - timer(3000, 3000).pipe( - switchMap(t => this.backupsState.load(true, true)), onErrorResumeNext()) + timer(3000, 3000).pipe(switchMap(t => this.backupsState.load(true, true).pipe(onErrorResumeNext()))) .subscribe(); } diff --git a/src/Squidex/app/shared/components/comments.component.ts b/src/Squidex/app/shared/components/comments.component.ts index a5490e183..a3b2926ff 100644 --- a/src/Squidex/app/shared/components/comments.component.ts +++ b/src/Squidex/app/shared/components/comments.component.ts @@ -26,7 +26,7 @@ import { templateUrl: './comments.component.html' }) export class CommentsComponent implements OnDestroy, OnInit { - private timer: Subscription; + private timerSubscription: Subscription; public state: CommentsState; @@ -47,13 +47,15 @@ export class CommentsComponent implements OnDestroy, OnInit { } public ngOnDestroy() { - this.timer.unsubscribe(); + this.timerSubscription.unsubscribe(); } public ngOnInit() { this.state = new CommentsState(this.appsState, this.commentsId, this.commentsService, this.dialogs); - this.timer = timer(0, 4000).pipe(switchMap(() => this.state.load()), onErrorResumeNext()).subscribe(); + this.timerSubscription = + timer(0, 4000).pipe(switchMap(() => this.state.load().pipe(onErrorResumeNext()))) + .subscribe(); } public delete(comment: CommentDto) { diff --git a/src/Squidex/app/shared/components/history.component.ts b/src/Squidex/app/shared/components/history.component.ts index 7182caec2..bb1eb37bf 100644 --- a/src/Squidex/app/shared/components/history.component.ts +++ b/src/Squidex/app/shared/components/history.component.ts @@ -8,7 +8,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { merge, Observable, timer } from 'rxjs'; -import { delay, switchMap } from 'rxjs/operators'; +import { delay, onErrorResumeNext, switchMap } from 'rxjs/operators'; import { allParams, @@ -33,7 +33,7 @@ export class HistoryComponent { timer(0, 10000), this.messageBus.of(HistoryChannelUpdated).pipe(delay(1000)) ).pipe( - switchMap(() => this.historyService.getHistory(this.appsState.appName, this.channel))); + switchMap(() => this.historyService.getHistory(this.appsState.appName, this.channel).pipe(onErrorResumeNext()))); constructor( private readonly appsState: AppsState,