From 1378c0d343028f3d40d7d795422684ab9e6a1599 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 17 Aug 2021 11:27:47 +0200 Subject: Fix client lint --- .../abuse-list-table.component.ts | 141 +++++++++++---------- .../abuse-message-modal.component.ts | 24 ++-- .../moderation-comment-modal.component.ts | 8 +- .../shared-custom-markup/custom-markup.service.ts | 4 +- .../channel-miniature-markup.component.ts | 8 +- .../playlist-miniature-markup.component.ts | 8 +- .../video-miniature-markup.component.ts | 8 +- .../videos-list-markup.component.ts | 8 +- .../instance-about-accordion.component.ts | 8 +- .../shared-main/auth/auth-interceptor.service.ts | 2 +- .../users/user-notifications.component.ts | 24 ++-- .../account-blocklist.component.ts | 8 +- .../report-modals/account-report.component.ts | 8 +- .../report-modals/comment-report.component.ts | 8 +- .../report-modals/video-report.component.ts | 8 +- .../server-blocklist.component.ts | 8 +- .../shared-moderation/user-ban-modal.component.ts | 8 +- .../user-moderation-dropdown.component.ts | 112 ++++++++-------- .../shared-moderation/video-block.component.ts | 8 +- .../shared/shared-search/find-in-bulk.service.ts | 2 +- .../user-interface-settings.component.ts | 27 ++-- .../user-video-settings.component.ts | 15 ++- .../subscribe-button.component.ts | 16 +-- .../shared-video-miniature/abstract-video-list.ts | 33 ++--- .../video-actions-dropdown.component.ts | 32 ++--- .../video-download.component.ts | 3 +- .../video-miniature.component.ts | 11 +- .../video-add-to-playlist.component.ts | 51 ++++---- .../video-playlist-element-miniature.component.ts | 16 +-- 29 files changed, 311 insertions(+), 306 deletions(-) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts index a7932ebab..e3bf9e1fb 100644 --- a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts +++ b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts @@ -145,23 +145,24 @@ export class AbuseListTableComponent extends RestTable implements OnInit { const res = await this.confirmService.confirm($localize`Do you really want to delete this abuse report?`, $localize`Delete`) if (res === false) return - this.abuseService.removeAbuse(abuse).subscribe( - () => { - this.notifier.success($localize`Abuse deleted.`) - this.reloadData() - }, + this.abuseService.removeAbuse(abuse) + .subscribe({ + next: () => { + this.notifier.success($localize`Abuse deleted.`) + this.reloadData() + }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } updateAbuseState (abuse: AdminAbuse, state: AbuseState) { this.abuseService.updateAbuse(abuse, { state }) - .subscribe( - () => this.reloadData(), + .subscribe({ + next: () => this.reloadData(), - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } onCountMessagesUpdated (event: { abuseId: number, countMessages: number }) { @@ -198,55 +199,55 @@ export class AbuseListTableComponent extends RestTable implements OnInit { ? this.abuseService.getAdminAbuses(options) : this.abuseService.getUserAbuses(options) - return observable.subscribe( - async resultList => { - this.totalRecords = resultList.total + return observable.subscribe({ + next: async resultList => { + this.totalRecords = resultList.total - this.abuses = [] + this.abuses = [] - for (const a of resultList.data) { - const abuse = a as ProcessedAbuse + for (const a of resultList.data) { + const abuse = a as ProcessedAbuse - abuse.reasonHtml = await this.toHtml(abuse.reason) + abuse.reasonHtml = await this.toHtml(abuse.reason) - if (abuse.moderationComment) { - abuse.moderationCommentHtml = await this.toHtml(abuse.moderationComment) - } + if (abuse.moderationComment) { + abuse.moderationCommentHtml = await this.toHtml(abuse.moderationComment) + } - if (abuse.video) { - abuse.embedHtml = this.sanitizer.bypassSecurityTrustHtml(this.getVideoEmbed(abuse)) + if (abuse.video) { + abuse.embedHtml = this.sanitizer.bypassSecurityTrustHtml(this.getVideoEmbed(abuse)) - if (abuse.video.channel?.ownerAccount) { - abuse.video.channel.ownerAccount = new Account(abuse.video.channel.ownerAccount) - } + if (abuse.video.channel?.ownerAccount) { + abuse.video.channel.ownerAccount = new Account(abuse.video.channel.ownerAccount) } + } - if (abuse.comment) { - if (abuse.comment.deleted) { - abuse.truncatedCommentHtml = abuse.commentHtml = $localize`Deleted comment` - } else { - const truncated = truncate(abuse.comment.text, { length: 100 }) - abuse.truncatedCommentHtml = await this.markdownRenderer.textMarkdownToHTML(truncated, true) - abuse.commentHtml = await this.markdownRenderer.textMarkdownToHTML(abuse.comment.text, true) - } + if (abuse.comment) { + if (abuse.comment.deleted) { + abuse.truncatedCommentHtml = abuse.commentHtml = $localize`Deleted comment` + } else { + const truncated = truncate(abuse.comment.text, { length: 100 }) + abuse.truncatedCommentHtml = await this.markdownRenderer.textMarkdownToHTML(truncated, true) + abuse.commentHtml = await this.markdownRenderer.textMarkdownToHTML(abuse.comment.text, true) } + } - if (abuse.reporterAccount) { - abuse.reporterAccount = new Account(abuse.reporterAccount) - } + if (abuse.reporterAccount) { + abuse.reporterAccount = new Account(abuse.reporterAccount) + } - if (abuse.flaggedAccount) { - abuse.flaggedAccount = new Account(abuse.flaggedAccount) - } + if (abuse.flaggedAccount) { + abuse.flaggedAccount = new Account(abuse.flaggedAccount) + } - if (abuse.updatedAt === abuse.createdAt) delete abuse.updatedAt + if (abuse.updatedAt === abuse.createdAt) delete abuse.updatedAt - this.abuses.push(abuse) - } - }, + this.abuses.push(abuse) + } + }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } private buildInternalActions (): DropdownAction[] { @@ -351,15 +352,15 @@ export class AbuseListTableComponent extends RestTable implements OnInit { isDisplayed: abuse => abuse.video && !abuse.video.deleted && !abuse.video.blacklisted, handler: abuse => { this.videoBlocklistService.blockVideo(abuse.video.id, undefined, abuse.video.channel.isLocal) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Video blocked.`) this.updateAbuseState(abuse, AbuseState.ACCEPTED) }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } }, { @@ -367,15 +368,15 @@ export class AbuseListTableComponent extends RestTable implements OnInit { isDisplayed: abuse => abuse.video && !abuse.video.deleted && abuse.video.blacklisted, handler: abuse => { this.videoBlocklistService.unblockVideo(abuse.video.id) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Video unblocked.`) this.updateAbuseState(abuse, AbuseState.ACCEPTED) }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } }, { @@ -389,15 +390,15 @@ export class AbuseListTableComponent extends RestTable implements OnInit { if (res === false) return this.videoService.removeVideo(abuse.video.id) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Video deleted.`) this.updateAbuseState(abuse, AbuseState.ACCEPTED) }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } } ] @@ -424,15 +425,15 @@ export class AbuseListTableComponent extends RestTable implements OnInit { if (res === false) return this.commentService.deleteVideoComment(abuse.comment.video.id, abuse.comment.id) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Comment deleted.`) this.updateAbuseState(abuse, AbuseState.ACCEPTED) }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } } ] @@ -440,25 +441,25 @@ export class AbuseListTableComponent extends RestTable implements OnInit { private muteAccountHelper (account: Account) { this.blocklistService.blockAccountByInstance(account) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Account ${account.nameWithHost} muted by the instance.`) account.mutedByInstance = true }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } private muteServerHelper (host: string) { this.blocklistService.blockServerByInstance(host) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Server ${host} muted by the instance.`) }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } private toHtml (text: string) { diff --git a/client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts b/client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts index 9abb4c094..6c8dc6d35 100644 --- a/client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts +++ b/client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts @@ -61,8 +61,8 @@ export class AbuseMessageModalComponent extends FormReactive implements OnInit { this.sendingMessage = true this.abuseService.addAbuseMessage(this.abuse, this.form.value['message']) - .subscribe( - () => { + .subscribe({ + next: () => { this.form.reset() this.sendingMessage = false this.countMessagesUpdated.emit({ abuseId: this.abuse.id, countMessages: this.abuseMessages.length + 1 }) @@ -70,25 +70,25 @@ export class AbuseMessageModalComponent extends FormReactive implements OnInit { this.loadMessages() }, - err => { + error: err => { this.sendingMessage = false console.error(err) this.notifier.error('Sorry but you cannot send this message. Please retry later') } - ) + }) } deleteMessage (abuseMessage: AbuseMessage) { this.abuseService.deleteAbuseMessage(this.abuse, abuseMessage) - .subscribe( - () => { + .subscribe({ + next: () => { this.countMessagesUpdated.emit({ abuseId: this.abuse.id, countMessages: this.abuseMessages.length - 1 }) this.abuseMessages = this.abuseMessages.filter(m => m.id !== abuseMessage.id) }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } isMessageByMe (abuseMessage: AbuseMessage) { @@ -105,8 +105,8 @@ export class AbuseMessageModalComponent extends FormReactive implements OnInit { private loadMessages () { this.abuseService.listAbuseMessages(this.abuse) - .subscribe( - async res => { + .subscribe({ + next: async res => { this.abuseMessages = [] for (const m of res.data) { @@ -124,8 +124,8 @@ export class AbuseMessageModalComponent extends FormReactive implements OnInit { }) }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } } diff --git a/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts b/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts index 876aeea8a..06f1555ea 100644 --- a/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts +++ b/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts @@ -53,16 +53,16 @@ export class ModerationCommentModalComponent extends FormReactive implements OnI const moderationComment: string = this.form.value[ 'moderationComment' ] this.abuseService.updateAbuse(this.abuseToComment, { moderationComment }) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Comment updated.`) this.commentUpdated.emit(moderationComment) this.hide() }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } } diff --git a/client/src/app/shared/shared-custom-markup/custom-markup.service.ts b/client/src/app/shared/shared-custom-markup/custom-markup.service.ts index c9d33980e..63f2f76f5 100644 --- a/client/src/app/shared/shared-custom-markup/custom-markup.service.ts +++ b/client/src/app/shared/shared-custom-markup/custom-markup.service.ts @@ -1,4 +1,4 @@ -import { first } from 'rxjs/operators' +import { firstValueFrom } from 'rxjs' import { ComponentRef, Injectable } from '@angular/core' import { MarkdownService } from '@app/core' import { @@ -85,7 +85,7 @@ export class CustomMarkupService { const component = this.execAngularBuilder(selector, e) if (component.instance.loaded) { - const p = component.instance.loaded.pipe(first()).toPromise() + const p = firstValueFrom(component.instance.loaded) loadedPromises.push(p) } diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts index 5bb045a82..8c1357d7a 100644 --- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts @@ -44,14 +44,14 @@ export class ChannelMiniatureMarkupComponent implements CustomMarkupComponent, O tap(html => this.descriptionHTML = html), switchMap(() => this.loadVideosObservable()), finalize(() => this.loaded.emit(true)) - ).subscribe( - ({ total, data }) => { + ).subscribe({ + next: ({ total, data }) => { this.totalVideos = total this.video = data[0] }, - err => this.notifier.error($localize`Error in channel miniature component: ${err.message}`) - ) + error: err => this.notifier.error($localize`Error in channel miniature component: ${err.message}`) + }) } getVideoChannelLink () { diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts index 5a5c34867..07fa6fd2d 100644 --- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts @@ -41,10 +41,10 @@ export class PlaylistMiniatureMarkupComponent implements CustomMarkupComponent, ngOnInit () { this.findInBulkService.getPlaylist(this.uuid) .pipe(finalize(() => this.loaded.emit(true))) - .subscribe( - playlist => this.playlist = playlist, + .subscribe({ + next: playlist => this.playlist = playlist, - err => this.notifier.error($localize`Error in playlist miniature component: ${err.message}`) - ) + error: err => this.notifier.error($localize`Error in playlist miniature component: ${err.message}`) + }) } } diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts index 84c936ee7..56b43d85e 100644 --- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts @@ -53,10 +53,10 @@ export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnI this.findInBulk.getVideo(this.uuid) .pipe(finalize(() => this.loaded.emit(true))) - .subscribe( - video => this.video = video, + .subscribe({ + next: video => this.video = video, - err => this.notifier.error($localize`Error in video miniature component: ${err.message}`) - ) + error: err => this.notifier.error($localize`Error in video miniature component: ${err.message}`) + }) } } diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts index 6473e9ba0..856e43681 100644 --- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts @@ -71,11 +71,11 @@ export class VideosListMarkupComponent implements CustomMarkupComponent, OnInit return this.getVideosObservable() .pipe(finalize(() => this.loaded.emit(true))) - .subscribe( - ({ data }) => this.videos = data, + .subscribe({ + next: ({ data }) => this.videos = data, - err => this.notifier.error($localize`Error in videos list component: ${err.message}`) - ) + error: err => this.notifier.error($localize`Error in videos list component: ${err.message}`) + }) } getVideosObservable () { diff --git a/client/src/app/shared/shared-instance/instance-about-accordion.component.ts b/client/src/app/shared/shared-instance/instance-about-accordion.component.ts index 8e7bf2021..855c06aa1 100644 --- a/client/src/app/shared/shared-instance/instance-about-accordion.component.ts +++ b/client/src/app/shared/shared-instance/instance-about-accordion.component.ts @@ -36,8 +36,8 @@ export class InstanceAboutAccordionComponent implements OnInit { ngOnInit (): void { this.instanceService.getAbout() - .subscribe( - async about => { + .subscribe({ + next: async about => { this.about = about this.aboutHtml = await this.instanceService.buildHtml(about) @@ -45,8 +45,8 @@ export class InstanceAboutAccordionComponent implements OnInit { this.init.emit(this) }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } getAdministratorsPanel () { diff --git a/client/src/app/shared/shared-main/auth/auth-interceptor.service.ts b/client/src/app/shared/shared-main/auth/auth-interceptor.service.ts index a75c8a25c..51248c7b2 100644 --- a/client/src/app/shared/shared-main/auth/auth-interceptor.service.ts +++ b/client/src/app/shared/shared-main/auth/auth-interceptor.service.ts @@ -36,7 +36,7 @@ export class AuthInterceptor implements HttpInterceptor { return this.handleNotAuthenticated(err) } - return observableThrowError(err) + return observableThrowError(() => err) }) ) } diff --git a/client/src/app/shared/shared-main/users/user-notifications.component.ts b/client/src/app/shared/shared-main/users/user-notifications.component.ts index 96b141543..50005b855 100644 --- a/client/src/app/shared/shared-main/users/user-notifications.component.ts +++ b/client/src/app/shared/shared-main/users/user-notifications.component.ts @@ -56,8 +56,8 @@ export class UserNotificationsComponent implements OnInit { } this.userNotificationService.listMyNotifications(options) - .subscribe( - result => { + .subscribe({ + next: result => { this.notifications = reset ? result.data : this.notifications.concat(result.data) this.componentPagination.totalItems = result.total @@ -66,8 +66,8 @@ export class UserNotificationsComponent implements OnInit { this.onDataSubject.next(result.data) }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } onNearOfBottom () { @@ -84,26 +84,26 @@ export class UserNotificationsComponent implements OnInit { if (notification.read) return this.userNotificationService.markAsRead(notification) - .subscribe( - () => { + .subscribe({ + next: () => { notification.read = true }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } markAllAsRead () { this.userNotificationService.markAllAsRead() - .subscribe( - () => { + .subscribe({ + next: () => { for (const notification of this.notifications) { notification.read = true } }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } changeSortColumn (column: string) { diff --git a/client/src/app/shared/shared-moderation/account-blocklist.component.ts b/client/src/app/shared/shared-moderation/account-blocklist.component.ts index 1146aeec0..36f2a591b 100644 --- a/client/src/app/shared/shared-moderation/account-blocklist.component.ts +++ b/client/src/app/shared/shared-moderation/account-blocklist.component.ts @@ -62,13 +62,13 @@ export class GenericAccountBlocklistComponent extends RestTable implements OnIni search: this.search }) - return operation.subscribe( - resultList => { + return operation.subscribe({ + next: resultList => { this.blockedAccounts = resultList.data this.totalRecords = resultList.total }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } } diff --git a/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts index cc8875f77..4ec02f11a 100644 --- a/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts +++ b/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts @@ -77,14 +77,14 @@ export class AccountReportComponent extends FormReactive implements OnInit { account: { id: this.account.id } - }).subscribe( - () => { + }).subscribe({ + next: () => { this.notifier.success($localize`Account reported.`) this.hide() }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } isRemote () { diff --git a/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts index c7395c7b7..7c0907ce4 100644 --- a/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts +++ b/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts @@ -77,14 +77,14 @@ export class CommentReportComponent extends FormReactive implements OnInit { comment: { id: this.comment.id } - }).subscribe( - () => { + }).subscribe({ + next: () => { this.notifier.success($localize`Comment reported.`) this.hide() }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } isRemote () { diff --git a/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts index e509ac88f..278d60ac6 100644 --- a/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts +++ b/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts @@ -108,14 +108,14 @@ export class VideoReportComponent extends FormReactive implements OnInit { startAt: hasStart && startAt ? startAt : undefined, endAt: hasEnd && endAt ? endAt : undefined } - }).subscribe( - () => { + }).subscribe({ + next: () => { this.notifier.success($localize`Video reported.`) this.hide() }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } isRemote () { diff --git a/client/src/app/shared/shared-moderation/server-blocklist.component.ts b/client/src/app/shared/shared-moderation/server-blocklist.component.ts index 274d8f6e9..da09b1d0e 100644 --- a/client/src/app/shared/shared-moderation/server-blocklist.component.ts +++ b/client/src/app/shared/shared-moderation/server-blocklist.component.ts @@ -88,13 +88,13 @@ export class GenericServerBlocklistComponent extends RestTable implements OnInit search: this.search }) - return operation.subscribe( - resultList => { + return operation.subscribe({ + next: resultList => { this.blockedServers = resultList.data this.totalRecords = resultList.total }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } } diff --git a/client/src/app/shared/shared-moderation/user-ban-modal.component.ts b/client/src/app/shared/shared-moderation/user-ban-modal.component.ts index afc69a1b8..0a2d5e93a 100644 --- a/client/src/app/shared/shared-moderation/user-ban-modal.component.ts +++ b/client/src/app/shared/shared-moderation/user-ban-modal.component.ts @@ -47,8 +47,8 @@ export class UserBanModalComponent extends FormReactive implements OnInit { const reason = this.form.value['reason'] || undefined this.userService.banUsers(this.usersToBan, reason) - .subscribe( - () => { + .subscribe({ + next: () => { const message = Array.isArray(this.usersToBan) ? $localize`${this.usersToBan.length} users banned.` : $localize`User ${this.usersToBan.username} banned.` @@ -59,8 +59,8 @@ export class UserBanModalComponent extends FormReactive implements OnInit { this.hide() }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } } diff --git a/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts b/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts index 8c5a48d42..9f1e1bf9b 100644 --- a/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts +++ b/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts @@ -67,14 +67,14 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { if (res === false) return this.userService.unbanUsers(user) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`User ${user.username} unbanned.`) this.userChanged.emit() }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } async removeUser (user: User) { @@ -87,137 +87,139 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { const res = await this.confirmService.confirm(message, $localize`Delete`) if (res === false) return - this.userService.removeUser(user).subscribe( - () => { - this.notifier.success($localize`User ${user.username} deleted.`) - this.userDeleted.emit() - }, + this.userService.removeUser(user) + .subscribe({ + next: () => { + this.notifier.success($localize`User ${user.username} deleted.`) + this.userDeleted.emit() + }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } setEmailAsVerified (user: User) { - this.userService.updateUser(user.id, { emailVerified: true }).subscribe( - () => { - this.notifier.success($localize`User ${user.username} email set as verified`) - this.userChanged.emit() - }, - - err => this.notifier.error(err.message) - ) + this.userService.updateUser(user.id, { emailVerified: true }) + .subscribe({ + next: () => { + this.notifier.success($localize`User ${user.username} email set as verified`) + this.userChanged.emit() + }, + + error: err => this.notifier.error(err.message) + }) } blockAccountByUser (account: Account) { this.blocklistService.blockAccountByUser(account) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Account ${account.nameWithHost} muted.`) this.account.mutedByUser = true this.userChanged.emit() }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } unblockAccountByUser (account: Account) { this.blocklistService.unblockAccountByUser(account) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Account ${account.nameWithHost} unmuted.`) this.account.mutedByUser = false this.userChanged.emit() }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } blockServerByUser (host: string) { this.blocklistService.blockServerByUser(host) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Instance ${host} muted.`) this.account.mutedServerByUser = true this.userChanged.emit() }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } unblockServerByUser (host: string) { this.blocklistService.unblockServerByUser(host) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Instance ${host} unmuted.`) this.account.mutedServerByUser = false this.userChanged.emit() }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } blockAccountByInstance (account: Account) { this.blocklistService.blockAccountByInstance(account) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Account ${account.nameWithHost} muted by the instance.`) this.account.mutedByInstance = true this.userChanged.emit() }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } unblockAccountByInstance (account: Account) { this.blocklistService.unblockAccountByInstance(account) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Account ${account.nameWithHost} unmuted by the instance.`) this.account.mutedByInstance = false this.userChanged.emit() }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } blockServerByInstance (host: string) { this.blocklistService.blockServerByInstance(host) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Instance ${host} muted by the instance.`) this.account.mutedServerByInstance = true this.userChanged.emit() }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } unblockServerByInstance (host: string) { this.blocklistService.unblockServerByInstance(host) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Instance ${host} unmuted by the instance.`) this.account.mutedServerByInstance = false this.userChanged.emit() }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } async bulkRemoveCommentsOf (body: BulkRemoveCommentsOfBody) { @@ -226,13 +228,13 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { if (res === false) return this.bulkService.removeCommentsOf(body) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Will remove comments of this account (may take several minutes).`) }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } getRouterUserEditLink (user: User) { diff --git a/client/src/app/shared/shared-moderation/video-block.component.ts b/client/src/app/shared/shared-moderation/video-block.component.ts index fb47989dc..bc6952620 100644 --- a/client/src/app/shared/shared-moderation/video-block.component.ts +++ b/client/src/app/shared/shared-moderation/video-block.component.ts @@ -55,8 +55,8 @@ export class VideoBlockComponent extends FormReactive implements OnInit { const unfederate = this.video.isLocal ? this.form.value[ 'unfederate' ] : undefined this.videoBlocklistService.blockVideo(this.video.id, reason, unfederate) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Video blocked.`) this.hide() @@ -66,7 +66,7 @@ export class VideoBlockComponent extends FormReactive implements OnInit { this.videoBlocked.emit() }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } } diff --git a/client/src/app/shared/shared-search/find-in-bulk.service.ts b/client/src/app/shared/shared-search/find-in-bulk.service.ts index 61dd2cbc5..962e374a5 100644 --- a/client/src/app/shared/shared-search/find-in-bulk.service.ts +++ b/client/src/app/shared/shared-search/find-in-bulk.service.ts @@ -1,5 +1,5 @@ import * as debug from 'debug' -import { Observable, Subject, throwError } from 'rxjs' +import { Observable, Subject } from 'rxjs' import { first, map } from 'rxjs/operators' import { Injectable, NgZone } from '@angular/core' import { buildBulkObservable } from '@app/helpers' diff --git a/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts b/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts index b721604e5..bd1cb0353 100644 --- a/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts +++ b/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts @@ -65,18 +65,21 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn } if (this.authService.isLoggedIn()) { - this.userService.updateMyProfile(details).subscribe( - () => { - this.authService.refreshUserInformation() - - if (this.notifyOnUpdate) this.notifier.success($localize`Interface settings updated.`) - }, - - err => this.notifier.error(err.message) - ) - } else { - this.userService.updateMyAnonymousProfile(details) - if (this.notifyOnUpdate) this.notifier.success($localize`Interface settings updated.`) + this.userService.updateMyProfile(details) + .subscribe({ + next: () => { + this.authService.refreshUserInformation() + + if (this.notifyOnUpdate) this.notifier.success($localize`Interface settings updated.`) + }, + + error: err => this.notifier.error(err.message) + }) + + return } + + this.userService.updateMyAnonymousProfile(details) + if (this.notifyOnUpdate) this.notifier.success($localize`Interface settings updated.`) } } diff --git a/client/src/app/shared/shared-user-settings/user-video-settings.component.ts b/client/src/app/shared/shared-user-settings/user-video-settings.component.ts index 8b0eaea4f..4aac60c2b 100644 --- a/client/src/app/shared/shared-user-settings/user-video-settings.component.ts +++ b/client/src/app/shared/shared-user-settings/user-video-settings.component.ts @@ -162,15 +162,16 @@ export class UserVideoSettingsComponent extends FormReactive implements OnInit, } private updateLoggedProfile (details: UserUpdateMe) { - this.userService.updateMyProfile(details).subscribe( - () => { - this.authService.refreshUserInformation() + this.userService.updateMyProfile(details) + .subscribe({ + next: () => { + this.authService.refreshUserInformation() - if (this.notifyOnUpdate) this.notifier.success($localize`Video settings updated.`) - }, + if (this.notifyOnUpdate) this.notifier.success($localize`Video settings updated.`) + }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } private updateAnonymousProfile (details: UserUpdateMe) { diff --git a/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts b/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts index 2261e07dd..796493bd9 100644 --- a/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts +++ b/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts @@ -102,8 +102,8 @@ export class SubscribeButtonComponent implements OnInit, OnChanges { .map(handle => this.userSubscriptionService.addSubscription(handle)) forkJoin(observableBatch) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success( this.account ? $localize`Subscribed to all current channels of ${this.account.displayName}. You will be notified of all their new videos.` @@ -113,8 +113,8 @@ export class SubscribeButtonComponent implements OnInit, OnChanges { ) }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } unsubscribe () { @@ -182,11 +182,11 @@ export class SubscribeButtonComponent implements OnInit, OnChanges { merge( this.userSubscriptionService.listenToSubscriptionCacheChange(handle), this.userSubscriptionService.doesSubscriptionExist(handle) - ).subscribe( - res => this.subscribed.set(handle, res), + ).subscribe({ + next: res => this.subscribed.set(handle, res), - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } } } diff --git a/client/src/app/shared/shared-video-miniature/abstract-video-list.ts b/client/src/app/shared/shared-video-miniature/abstract-video-list.ts index 33061a837..d8b2ee17d 100644 --- a/client/src/app/shared/shared-video-miniature/abstract-video-list.ts +++ b/client/src/app/shared/shared-video-miniature/abstract-video-list.ts @@ -204,28 +204,29 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte } loadMoreVideos (reset = false) { - this.getVideosObservable(this.pagination.currentPage).subscribe( - ({ data }) => { - this.hasDoneFirstQuery = true - this.lastQueryLength = data.length + this.getVideosObservable(this.pagination.currentPage) + .subscribe({ + next: ({ data }) => { + this.hasDoneFirstQuery = true + this.lastQueryLength = data.length - if (reset) this.videos = [] - this.videos = this.videos.concat(data) + if (reset) this.videos = [] + this.videos = this.videos.concat(data) - if (this.groupByDate) this.buildGroupedDateLabels() + if (this.groupByDate) this.buildGroupedDateLabels() - this.onMoreVideos() + this.onMoreVideos() - this.onDataSubject.next(data) - }, + this.onDataSubject.next(data) + }, - error => { - const message = $localize`Cannot load more videos. Try again later.` + error: err => { + const message = $localize`Cannot load more videos. Try again later.` - console.error(message, { error }) - this.notifier.error(message) - } - ) + console.error(message, { err }) + this.notifier.error(message) + } + }) } reloadVideos () { diff --git a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts index 3c2b46d16..2ba091438 100644 --- a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts +++ b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts @@ -183,8 +183,8 @@ export class VideoActionsDropdownComponent implements OnChanges { if (res === false) return this.videoBlocklistService.unblockVideo(this.video.id) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Video ${this.video.name} unblocked.`) this.video.blacklisted = false @@ -193,8 +193,8 @@ export class VideoActionsDropdownComponent implements OnChanges { this.videoUnblocked.emit() }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } async removeVideo () { @@ -209,40 +209,40 @@ export class VideoActionsDropdownComponent implements OnChanges { if (res === false) return this.videoService.removeVideo(this.video.id) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Video ${this.video.name} deleted.`) this.videoRemoved.emit() }, - error => this.notifier.error(error.message) - ) + error: err => this.notifier.error(err.message) + }) } duplicateVideo () { this.redundancyService.addVideoRedundancy(this.video) - .subscribe( - () => { + .subscribe({ + next: () => { const message = $localize`This video will be duplicated by your instance.` this.notifier.success(message) }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } muteVideoAccount () { const params = { nameWithHost: Actor.CREATE_BY_STRING(this.video.account.name, this.video.account.host) } this.blocklistService.blockAccountByUser(params) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Account ${params.nameWithHost} muted.`) this.videoAccountMuted.emit() }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } onVideoBlocked () { diff --git a/client/src/app/shared/shared-video-miniature/video-download.component.ts b/client/src/app/shared/shared-video-miniature/video-download.component.ts index 355ce8be3..28fefb9dd 100644 --- a/client/src/app/shared/shared-video-miniature/video-download.component.ts +++ b/client/src/app/shared/shared-video-miniature/video-download.component.ts @@ -1,4 +1,5 @@ import { mapValues, pick } from 'lodash-es' +import { firstValueFrom } from 'rxjs' import { tap } from 'rxjs/operators' import { Component, ElementRef, Inject, LOCALE_ID, ViewChild } from '@angular/core' import { AuthService, HooksService, Notifier } from '@app/core' @@ -265,6 +266,6 @@ export class VideoDownloadComponent { const observable = this.videoService.getVideoFileMetadata(file.metadataUrl) .pipe(tap(res => file.metadata = res)) - return observable.toPromise() + return firstValueFrom(observable) } } diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts index 67e0de6a2..cb81ba3bd 100644 --- a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts +++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts @@ -214,11 +214,12 @@ export class VideoMiniatureComponent implements OnInit { addToWatchLater () { const body = { videoId: this.video.id } - this.videoPlaylistService.addVideoInPlaylist(this.watchLaterPlaylist.id, body).subscribe( - res => { - this.watchLaterPlaylist.playlistElementId = res.videoPlaylistElement.id - } - ) + this.videoPlaylistService.addVideoInPlaylist(this.watchLaterPlaylist.id, body) + .subscribe( + res => { + this.watchLaterPlaylist.playlistElementId = res.videoPlaylistElement.id + } + ) } removeFromWatchLater () { diff --git a/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts b/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts index 7069fa8fd..df3aeddb7 100644 --- a/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts +++ b/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts @@ -198,15 +198,16 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit, privacy: VideoPlaylistPrivacy.PRIVATE } - this.videoPlaylistService.createVideoPlaylist(videoPlaylistCreate).subscribe( - () => { - this.isNewPlaylistBlockOpened = false + this.videoPlaylistService.createVideoPlaylist(videoPlaylistCreate) + .subscribe({ + next: () => { + this.isNewPlaylistBlockOpened = false - this.cd.markForCheck() - }, + this.cd.markForCheck() + }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } onVideoPlaylistSearchChanged () { @@ -268,17 +269,15 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit, } this.videoPlaylistService.updateVideoOfPlaylist(playlist.id, element.playlistElementId, body, this.video.id) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Timestamps updated`) }, - err => { - this.notifier.error(err.message) - }, + error: err => this.notifier.error(err.message), - () => this.cd.markForCheck() - ) + complete: () => this.cd.markForCheck() + }) } private isOptionalRowDisplayed (playlist: PlaylistSummary) { @@ -302,17 +301,15 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit, private removeVideoFromPlaylist (playlist: PlaylistSummary, elementId: number) { this.videoPlaylistService.removeVideoFromPlaylist(playlist.id, elementId, this.video.id) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Video removed from ${playlist.displayName}`) }, - err => { - this.notifier.error(err.message) - }, + error: err => this.notifier.error(err.message), - () => this.cd.markForCheck() - ) + complete: () => this.cd.markForCheck() + }) } private listenToVideoPlaylistChange () { @@ -371,8 +368,8 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit, if (element.stopTimestamp && element.stopTimestamp !== this.video.duration) body.stopTimestamp = element.stopTimestamp this.videoPlaylistService.addVideoInPlaylist(playlist.id, body) - .subscribe( - res => { + .subscribe({ + next: res => { const message = body.startTimestamp || body.stopTimestamp ? $localize`Video added in ${playlist.displayName} at timestamps ${this.formatTimestamp(element)}` : $localize`Video added in ${playlist.displayName}` @@ -382,12 +379,10 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit, if (element) element.playlistElementId = res.videoPlaylistElement.id }, - err => { - this.notifier.error(err.message) - }, + error: err => this.notifier.error(err.message), - () => this.cd.markForCheck() - ) + complete: () => this.cd.markForCheck() + }) } private formatTimestamp (element: PlaylistElement) { diff --git a/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts b/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts index 2e495ec26..8d1e14f94 100644 --- a/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts +++ b/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts @@ -88,14 +88,14 @@ export class VideoPlaylistElementMiniatureComponent implements OnInit { const videoId = this.playlistElement.video ? this.playlistElement.video.id : undefined this.videoPlaylistService.removeVideoFromPlaylist(this.playlist.id, playlistElement.id, videoId) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Video removed from ${this.playlist.displayName}`) this.elementRemoved.emit(playlistElement) }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) this.moreDropdown.close() } @@ -107,8 +107,8 @@ export class VideoPlaylistElementMiniatureComponent implements OnInit { body.stopTimestamp = this.timestampOptions.stopTimestampEnabled ? this.timestampOptions.stopTimestamp : null this.videoPlaylistService.updateVideoOfPlaylist(this.playlist.id, playlistElement.id, body, this.playlistElement.video.id) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`Timestamps updated`) playlistElement.startTimestamp = body.startTimestamp @@ -117,8 +117,8 @@ export class VideoPlaylistElementMiniatureComponent implements OnInit { this.cdr.detectChanges() }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) this.moreDropdown.close() } -- cgit v1.2.3