Fix client lint

This commit is contained in:
Chocobozzz 2021-08-17 11:27:47 +02:00
parent c186a67f90
commit 1378c0d343
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
102 changed files with 1053 additions and 1031 deletions

View File

@ -91,8 +91,8 @@ export class AboutFollowsComponent implements OnInit {
const pagination = this.restService.componentPaginationToRestPagination(this.followersPagination) const pagination = this.restService.componentPaginationToRestPagination(this.followersPagination)
this.followService.getFollowers({ pagination: pagination, sort: this.sort, state: 'accepted' }) this.followService.getFollowers({ pagination: pagination, sort: this.sort, state: 'accepted' })
.subscribe( .subscribe({
resultList => { next: resultList => {
if (reset) this.followers = [] if (reset) this.followers = []
const newFollowers = resultList.data.map(r => r.follower.host) const newFollowers = resultList.data.map(r => r.follower.host)
@ -101,16 +101,16 @@ export class AboutFollowsComponent implements OnInit {
this.followersPagination.totalItems = resultList.total this.followersPagination.totalItems = resultList.total
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
private loadMoreFollowings (reset = false) { private loadMoreFollowings (reset = false) {
const pagination = this.restService.componentPaginationToRestPagination(this.followingsPagination) const pagination = this.restService.componentPaginationToRestPagination(this.followingsPagination)
this.followService.getFollowing({ pagination, sort: this.sort, state: 'accepted' }) this.followService.getFollowing({ pagination, sort: this.sort, state: 'accepted' })
.subscribe( .subscribe({
resultList => { next: resultList => {
if (reset) this.followings = [] if (reset) this.followings = []
const newFollowings = resultList.data.map(r => r.following.host) const newFollowings = resultList.data.map(r => r.following.host)
@ -119,8 +119,8 @@ export class AboutFollowsComponent implements OnInit {
this.followingsPagination.totalItems = resultList.total this.followingsPagination.totalItems = resultList.total
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -83,18 +83,18 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit {
const body = this.form.value[ 'body' ] const body = this.form.value[ 'body' ]
this.instanceService.contactAdministrator(fromEmail, fromName, subject, body) this.instanceService.contactAdministrator(fromEmail, fromName, subject, body)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Your message has been sent.`) this.notifier.success($localize`Your message has been sent.`)
this.hide() this.hide()
}, },
err => { error: err => {
this.error = err.status === HttpStatusCode.FORBIDDEN_403 this.error = err.status === HttpStatusCode.FORBIDDEN_403
? $localize`You already sent this form recently` ? $localize`You already sent this form recently`
: err.message : err.message
} }
) })
} }
private prefillForm (prefill: Prefill) { private prefillForm (prefill: Prefill) {

View File

@ -71,11 +71,11 @@ export class AccountsComponent implements OnInit, OnDestroy {
HttpStatusCode.NOT_FOUND_404 HttpStatusCode.NOT_FOUND_404
])) ]))
) )
.subscribe( .subscribe({
videoChannels => this.videoChannels = videoChannels.data, next: videoChannels => this.videoChannels = videoChannels.data,
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
this.links = [ this.links = [
{ label: $localize`CHANNELS`, routerLink: 'video-channels' }, { label: $localize`CHANNELS`, routerLink: 'video-channels' },
@ -174,11 +174,12 @@ export class AccountsComponent implements OnInit, OnDestroy {
const user = this.authService.getUser() const user = this.authService.getUser()
if (user.hasRight(UserRight.MANAGE_USERS)) { if (user.hasRight(UserRight.MANAGE_USERS)) {
this.userService.getUser(account.userId).subscribe( this.userService.getUser(account.userId)
accountUser => this.accountUser = accountUser, .subscribe({
next: accountUser => this.accountUser = accountUser,
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -267,8 +267,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
this.configService.updateCustomConfig(omit(value, 'instanceCustomHomepage')), this.configService.updateCustomConfig(omit(value, 'instanceCustomHomepage')),
this.customPage.updateInstanceHomepage(value.instanceCustomHomepage.content) this.customPage.updateInstanceHomepage(value.instanceCustomHomepage.content)
]) ])
.subscribe( .subscribe({
([ resConfig ]) => { next: ([ resConfig ]) => {
const instanceCustomHomepage = { const instanceCustomHomepage = {
content: value.instanceCustomHomepage.content content: value.instanceCustomHomepage.content
} }
@ -284,8 +284,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
this.notifier.success($localize`Configuration updated.`) this.notifier.success($localize`Configuration updated.`)
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
hasConsistentOptions () { hasConsistentOptions () {
@ -339,8 +339,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
forkJoin([ forkJoin([
this.configService.getCustomConfig(), this.configService.getCustomConfig(),
this.customPage.getInstanceHomepage() this.customPage.getInstanceHomepage()
]) ]).subscribe({
.subscribe(([ config, homepage ]) => { next: ([ config, homepage ]) => {
this.customConfig = { ...config, instanceCustomHomepage: homepage } this.customConfig = { ...config, instanceCustomHomepage: homepage }
this.updateForm() this.updateForm()
@ -348,21 +348,21 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
this.forceCheck() this.forceCheck()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
private loadCategoriesAndLanguages () { private loadCategoriesAndLanguages () {
forkJoin([ forkJoin([
this.serverService.getVideoLanguages(), this.serverService.getVideoLanguages(),
this.serverService.getVideoCategories() this.serverService.getVideoCategories()
]).subscribe( ]).subscribe({
([ languages, categories ]) => { next: ([ languages, categories ]) => {
this.languageItems = languages.map(l => ({ label: l.label, id: l.id })) this.languageItems = languages.map(l => ({ label: l.label, id: l.id }))
this.categoryItems = categories.map(l => ({ label: l.label, id: l.id + '' })) this.categoryItems = categories.map(l => ({ label: l.label, id: l.id + '' }))
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -35,17 +35,17 @@ export class FollowersListComponent extends RestTable implements OnInit {
follow.state = 'accepted' follow.state = 'accepted'
this.followService.acceptFollower(follow) this.followService.acceptFollower(follow)
.subscribe( .subscribe({
() => { next: () => {
const handle = follow.follower.name + '@' + follow.follower.host const handle = follow.follower.name + '@' + follow.follower.host
this.notifier.success($localize`${handle} accepted in instance followers`) this.notifier.success($localize`${handle} accepted in instance followers`)
}, },
err => { error: err => {
follow.state = 'pending' follow.state = 'pending'
this.notifier.error(err.message) this.notifier.error(err.message)
} }
) })
} }
async rejectFollower (follow: ActorFollow) { async rejectFollower (follow: ActorFollow) {
@ -54,19 +54,19 @@ export class FollowersListComponent extends RestTable implements OnInit {
if (res === false) return if (res === false) return
this.followService.rejectFollower(follow) this.followService.rejectFollower(follow)
.subscribe( .subscribe({
() => { next: () => {
const handle = follow.follower.name + '@' + follow.follower.host const handle = follow.follower.name + '@' + follow.follower.host
this.notifier.success($localize`${handle} rejected from instance followers`) this.notifier.success($localize`${handle} rejected from instance followers`)
this.reloadData() this.reloadData()
}, },
err => { error: err => {
follow.state = 'pending' follow.state = 'pending'
this.notifier.error(err.message) this.notifier.error(err.message)
} }
) })
} }
async deleteFollower (follow: ActorFollow) { async deleteFollower (follow: ActorFollow) {
@ -75,27 +75,27 @@ export class FollowersListComponent extends RestTable implements OnInit {
if (res === false) return if (res === false) return
this.followService.removeFollower(follow) this.followService.removeFollower(follow)
.subscribe( .subscribe({
() => { next: () => {
const handle = follow.follower.name + '@' + follow.follower.host const handle = follow.follower.name + '@' + follow.follower.host
this.notifier.success($localize`${handle} removed from instance followers`) this.notifier.success($localize`${handle} removed from instance followers`)
this.reloadData() this.reloadData()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
protected reloadData () { protected reloadData () {
this.followService.getFollowers({ pagination: this.pagination, sort: this.sort, search: this.search }) this.followService.getFollowers({ pagination: this.pagination, sort: this.sort, search: this.search })
.subscribe( .subscribe({
resultList => { next: resultList => {
this.followers = resultList.data this.followers = resultList.data
this.totalRecords = resultList.total this.totalRecords = resultList.total
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -57,13 +57,14 @@ export class FollowModalComponent extends FormReactive implements OnInit {
private async addFollowing () { private async addFollowing () {
const hostsOrHandles = splitAndGetNotEmpty(this.form.value['hostsOrHandles']) const hostsOrHandles = splitAndGetNotEmpty(this.form.value['hostsOrHandles'])
this.followService.follow(hostsOrHandles).subscribe( this.followService.follow(hostsOrHandles)
() => { .subscribe({
next: () => {
this.notifier.success($localize`Follow request(s) sent!`) this.notifier.success($localize`Follow request(s) sent!`)
this.newFollow.emit() this.newFollow.emit()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -49,25 +49,26 @@ export class FollowingListComponent extends RestTable implements OnInit {
) )
if (res === false) return if (res === false) return
this.followService.unfollow(follow).subscribe( this.followService.unfollow(follow)
() => { .subscribe({
next: () => {
this.notifier.success($localize`You are not following ${follow.following.host} anymore.`) this.notifier.success($localize`You are not following ${follow.following.host} anymore.`)
this.reloadData() this.reloadData()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
protected reloadData () { protected reloadData () {
this.followService.getFollowing({ pagination: this.pagination, sort: this.sort, search: this.search }) this.followService.getFollowing({ pagination: this.pagination, sort: this.sort, search: this.search })
.subscribe( .subscribe({
resultList => { next: resultList => {
this.following = resultList.data this.following = resultList.data
this.totalRecords = resultList.total this.totalRecords = resultList.total
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -18,14 +18,14 @@ export class RedundancyCheckboxComponent {
updateRedundancyState () { updateRedundancyState () {
this.redundancyService.updateRedundancy(this.host, this.redundancyAllowed) this.redundancyService.updateRedundancy(this.host, this.redundancyAllowed)
.subscribe( .subscribe({
() => { next: () => {
const stateLabel = this.redundancyAllowed ? $localize`enabled` : $localize`disabled` const stateLabel = this.redundancyAllowed ? $localize`enabled` : $localize`disabled`
this.notifier.success($localize`Redundancy for ${this.host} is ${stateLabel}`) this.notifier.success($localize`Redundancy for ${this.host} is ${stateLabel}`)
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -142,14 +142,14 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit
if (res === false) return if (res === false) return
this.redundancyService.removeVideoRedundancies(redundancy) this.redundancyService.removeVideoRedundancies(redundancy)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Video redundancies removed!`) this.notifier.success($localize`Video redundancies removed!`)
this.reloadData() this.reloadData()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
@ -161,14 +161,14 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit
} }
this.redundancyService.listVideoRedundancies(options) this.redundancyService.listVideoRedundancies(options)
.subscribe( .subscribe({
resultList => { next: resultList => {
this.videoRedundancies = resultList.data this.videoRedundancies = resultList.data
this.totalRecords = resultList.total this.totalRecords = resultList.total
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
private loadSelectLocalStorage () { private loadSelectLocalStorage () {

View File

@ -62,14 +62,14 @@ export class VideoBlockListComponent extends RestTable implements OnInit {
handler: videoBlock => { handler: videoBlock => {
this.videoBlocklistService.unblockVideo(videoBlock.video.id).pipe( this.videoBlocklistService.unblockVideo(videoBlock.video.id).pipe(
switchMap(_ => this.videoBlocklistService.blockVideo(videoBlock.video.id, undefined, true)) switchMap(_ => this.videoBlocklistService.blockVideo(videoBlock.video.id, undefined, true))
).subscribe( ).subscribe({
() => { next: () => {
this.notifier.success($localize`Video ${videoBlock.video.name} switched to manual block.`) this.notifier.success($localize`Video ${videoBlock.video.name} switched to manual block.`)
this.reloadData() this.reloadData()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
}, },
isDisplayed: videoBlock => videoBlock.type === VideoBlacklistType.AUTO_BEFORE_PUBLISHED isDisplayed: videoBlock => videoBlock.type === VideoBlacklistType.AUTO_BEFORE_PUBLISHED
} }
@ -94,13 +94,11 @@ export class VideoBlockListComponent extends RestTable implements OnInit {
if (res === false) return if (res === false) return
this.videoService.removeVideo(videoBlock.video.id) this.videoService.removeVideo(videoBlock.video.id)
.subscribe( .subscribe({
() => { next: () => this.notifier.success($localize`Video deleted.`),
this.notifier.success($localize`Video deleted.`)
},
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }
] ]
@ -136,14 +134,15 @@ export class VideoBlockListComponent extends RestTable implements OnInit {
const res = await this.confirmService.confirm(confirmMessage, $localize`Unblock`) const res = await this.confirmService.confirm(confirmMessage, $localize`Unblock`)
if (res === false) return if (res === false) return
this.videoBlocklistService.unblockVideo(entry.video.id).subscribe( this.videoBlocklistService.unblockVideo(entry.video.id)
() => { .subscribe({
next: () => {
this.notifier.success($localize`Video ${entry.video.name} unblocked.`) this.notifier.success($localize`Video ${entry.video.name} unblocked.`)
this.reloadData() this.reloadData()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
getVideoEmbed (entry: VideoBlacklist) { getVideoEmbed (entry: VideoBlacklist) {
@ -164,8 +163,8 @@ export class VideoBlockListComponent extends RestTable implements OnInit {
sort: this.sort, sort: this.sort,
search: this.search search: this.search
}) })
.subscribe( .subscribe({
async resultList => { next: async resultList => {
this.totalRecords = resultList.total this.totalRecords = resultList.total
this.blocklist = resultList.data this.blocklist = resultList.data
@ -178,7 +177,7 @@ export class VideoBlockListComponent extends RestTable implements OnInit {
} }
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -34,13 +34,13 @@
<ng-template pTemplate="header"> <ng-template pTemplate="header">
<tr> <tr>
<th style="width: 40px"> <th style="width: 40px;">
<p-tableHeaderCheckbox ariaLabel="Select all rows" i18n-ariaLabel></p-tableHeaderCheckbox> <p-tableHeaderCheckbox ariaLabel="Select all rows" i18n-ariaLabel></p-tableHeaderCheckbox>
</th> </th>
<th style="width: 40px"></th> <th style="width: 40px;"></th>
<th style="width: 150px;"></th> <th style="width: 150px;"></th>
<th style="width: 300px" i18n>Account</th> <th style="width: 300px;" i18n>Account</th>
<th style="width: 300px" i18n>Video</th> <th style="width: 300px;" i18n>Video</th>
<th i18n>Comment</th> <th i18n>Comment</th>
<th style="width: 150px;" i18n pSortableColumn="createdAt">Date <p-sortIcon field="createdAt"></p-sortIcon></th> <th style="width: 150px;" i18n pSortableColumn="createdAt">Date <p-sortIcon field="createdAt"></p-sortIcon></th>
</tr> </tr>

View File

@ -1,5 +1,5 @@
import { SortMeta } from 'primeng/api' import { SortMeta } from 'primeng/api'
import { AfterViewInit, Component, OnInit } from '@angular/core' import { Component, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router' import { ActivatedRoute, Router } from '@angular/router'
import { AuthService, ConfirmService, MarkdownService, Notifier, RestPagination, RestTable } from '@app/core' import { AuthService, ConfirmService, MarkdownService, Notifier, RestPagination, RestTable } from '@app/core'
import { AdvancedInputFilter } from '@app/shared/shared-forms' import { AdvancedInputFilter } from '@app/shared/shared-forms'
@ -117,8 +117,8 @@ export class VideoCommentListComponent extends RestTable implements OnInit {
pagination: this.pagination, pagination: this.pagination,
sort: this.sort, sort: this.sort,
search: this.search search: this.search
}).subscribe( }).subscribe({
async resultList => { next: async resultList => {
this.totalRecords = resultList.total this.totalRecords = resultList.total
this.comments = [] this.comments = []
@ -130,32 +130,33 @@ export class VideoCommentListComponent extends RestTable implements OnInit {
} }
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
private async removeComments (comments: VideoCommentAdmin[]) { private async removeComments (comments: VideoCommentAdmin[]) {
const commentArgs = comments.map(c => ({ videoId: c.video.id, commentId: c.id })) const commentArgs = comments.map(c => ({ videoId: c.video.id, commentId: c.id }))
this.videoCommentService.deleteVideoComments(commentArgs).subscribe( this.videoCommentService.deleteVideoComments(commentArgs)
() => { .subscribe({
next: () => {
this.notifier.success($localize`${commentArgs.length} comments deleted.`) this.notifier.success($localize`${commentArgs.length} comments deleted.`)
this.reloadData() this.reloadData()
}, },
err => this.notifier.error(err.message), error: err => this.notifier.error(err.message),
() => this.selectedComments = [] complete: () => this.selectedComments = []
) })
} }
private deleteComment (comment: VideoCommentAdmin) { private deleteComment (comment: VideoCommentAdmin) {
this.videoCommentService.deleteVideoComment(comment.video.id, comment.id) this.videoCommentService.deleteVideoComment(comment.video.id, comment.id)
.subscribe( .subscribe({
() => this.reloadData(), next: () => this.reloadData(),
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
private async deleteUserComments (comment: VideoCommentAdmin) { private async deleteUserComments (comment: VideoCommentAdmin) {
@ -169,12 +170,12 @@ export class VideoCommentListComponent extends RestTable implements OnInit {
} }
this.bulkService.removeCommentsOf(options) this.bulkService.removeCommentsOf(options)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Comments of ${options.accountName} will be deleted in a few minutes`) this.notifier.success($localize`Comments of ${options.accountName} will be deleted in a few minutes`)
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -61,16 +61,16 @@ export class PluginListInstalledComponent implements OnInit {
loadMorePlugins () { loadMorePlugins () {
this.pluginApiService.getPlugins(this.pluginType, this.pagination, this.sort) this.pluginApiService.getPlugins(this.pluginType, this.pagination, this.sort)
.subscribe( .subscribe({
res => { next: res => {
this.plugins = this.plugins.concat(res.data) this.plugins = this.plugins.concat(res.data)
this.pagination.totalItems = res.total this.pagination.totalItems = res.total
this.onDataSubject.next(res.data) this.onDataSubject.next(res.data)
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
onNearOfBottom () { onNearOfBottom () {
@ -113,16 +113,16 @@ export class PluginListInstalledComponent implements OnInit {
if (res === false) return if (res === false) return
this.pluginApiService.uninstall(plugin.name, plugin.type) this.pluginApiService.uninstall(plugin.name, plugin.type)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`${plugin.name} uninstalled.`) this.notifier.success($localize`${plugin.name} uninstalled.`)
this.plugins = this.plugins.filter(p => p.name !== plugin.name) this.plugins = this.plugins.filter(p => p.name !== plugin.name)
this.pagination.totalItems-- this.pagination.totalItems--
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
async update (plugin: PeerTubePlugin) { async update (plugin: PeerTubePlugin) {
@ -143,8 +143,8 @@ export class PluginListInstalledComponent implements OnInit {
this.pluginApiService.update(plugin.name, plugin.type) this.pluginApiService.update(plugin.name, plugin.type)
.pipe() .pipe()
.subscribe( .subscribe({
res => { next: res => {
this.updating[updatingKey] = false this.updating[updatingKey] = false
this.notifier.success($localize`${plugin.name} updated.`) this.notifier.success($localize`${plugin.name} updated.`)
@ -152,8 +152,8 @@ export class PluginListInstalledComponent implements OnInit {
Object.assign(plugin, res) Object.assign(plugin, res)
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
getShowRouterLink (plugin: PeerTubePlugin) { getShowRouterLink (plugin: PeerTubePlugin) {

View File

@ -84,8 +84,8 @@ export class PluginSearchComponent implements OnInit {
this.isSearching = true this.isSearching = true
this.pluginApiService.searchAvailablePlugins(this.pluginType, this.pagination, this.sort, this.search) this.pluginApiService.searchAvailablePlugins(this.pluginType, this.pagination, this.sort, this.search)
.subscribe( .subscribe({
res => { next: res => {
this.isSearching = false this.isSearching = false
this.plugins = this.plugins.concat(res.data) this.plugins = this.plugins.concat(res.data)
@ -94,13 +94,13 @@ export class PluginSearchComponent implements OnInit {
this.onDataSubject.next(res.data) this.onDataSubject.next(res.data)
}, },
err => { error: err => {
console.error(err) console.error(err)
const message = $localize`The plugin index is not available. Please retry later.` const message = $localize`The plugin index is not available. Please retry later.`
this.notifier.error(message) this.notifier.error(message)
} }
) })
} }
onNearOfBottom () { onNearOfBottom () {
@ -139,8 +139,8 @@ export class PluginSearchComponent implements OnInit {
this.installing[plugin.npmName] = true this.installing[plugin.npmName] = true
this.pluginApiService.install(plugin.npmName) this.pluginApiService.install(plugin.npmName)
.subscribe( .subscribe({
() => { next: () => {
this.installing[plugin.npmName] = false this.installing[plugin.npmName] = false
this.pluginInstalled = true this.pluginInstalled = true
@ -149,7 +149,7 @@ export class PluginSearchComponent implements OnInit {
plugin.installed = true plugin.installed = true
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -50,13 +50,13 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit
const settings = this.form.value const settings = this.form.value
this.pluginAPIService.updatePluginSettings(this.plugin.name, this.plugin.type, settings) this.pluginAPIService.updatePluginSettings(this.plugin.name, this.plugin.type, settings)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Settings updated.`) this.notifier.success($localize`Settings updated.`)
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
hasRegisteredSettings () { hasRegisteredSettings () {
@ -83,8 +83,8 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit
return this.pluginAPIService.getPluginRegisteredSettings(plugin.name, plugin.type) return this.pluginAPIService.getPluginRegisteredSettings(plugin.name, plugin.type)
.pipe(map(data => ({ plugin, registeredSettings: data.registeredSettings }))) .pipe(map(data => ({ plugin, registeredSettings: data.registeredSettings })))
})) }))
.subscribe( .subscribe({
async ({ plugin, registeredSettings }) => { next: async ({ plugin, registeredSettings }) => {
this.plugin = plugin this.plugin = plugin
this.registeredSettings = await this.translateSettings(registeredSettings) this.registeredSettings = await this.translateSettings(registeredSettings)
@ -94,8 +94,8 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit
this.buildSettingsForm() this.buildSettingsForm()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
private buildSettingsForm () { private buildSettingsForm () {

View File

@ -22,10 +22,10 @@ export class DebugComponent implements OnInit {
load () { load () {
this.debugService.getDebug() this.debugService.getDebug()
.subscribe( .subscribe({
debug => this.debug = debug, next: debug => this.debug = debug,
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -119,14 +119,14 @@ export class JobsComponent extends RestTable implements OnInit {
pagination: this.pagination, pagination: this.pagination,
sort: this.sort sort: this.sort
}) })
.subscribe( .subscribe({
resultList => { next: resultList => {
this.jobs = resultList.data this.jobs = resultList.data
this.totalRecords = resultList.total this.totalRecords = resultList.total
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
private loadJobStateAndType () { private loadJobStateAndType () {

View File

@ -52,8 +52,8 @@ export class LogsComponent implements OnInit {
this.loading = true this.loading = true
this.logsService.getLogs({ isAuditLog: this.isAuditLog(), level: this.level, startDate: this.startDate }) this.logsService.getLogs({ isAuditLog: this.isAuditLog(), level: this.level, startDate: this.startDate })
.subscribe( .subscribe({
logs => { next: logs => {
this.logs = logs this.logs = logs
setTimeout(() => { setTimeout(() => {
@ -61,10 +61,10 @@ export class LogsComponent implements OnInit {
}) })
}, },
err => this.notifier.error(err.message), error: err => this.notifier.error(err.message),
() => this.loading = false complete: () => this.loading = false
) })
} }
isAuditLog () { isAuditLog () {

View File

@ -71,14 +71,15 @@ export class UserCreateComponent extends UserEdit implements OnInit {
userCreate.videoQuota = parseInt(this.form.value['videoQuota'], 10) userCreate.videoQuota = parseInt(this.form.value['videoQuota'], 10)
userCreate.videoQuotaDaily = parseInt(this.form.value['videoQuotaDaily'], 10) userCreate.videoQuotaDaily = parseInt(this.form.value['videoQuotaDaily'], 10)
this.userService.addUser(userCreate).subscribe( this.userService.addUser(userCreate)
() => { .subscribe({
next: () => {
this.notifier.success($localize`User ${userCreate.username} created.`) this.notifier.success($localize`User ${userCreate.username} created.`)
this.router.navigate([ '/admin/users/list' ]) this.router.navigate([ '/admin/users/list' ])
}, },
err => this.error = err.message error: err => this.error = err.message
) })
} }
isCreation () { isCreation () {

View File

@ -35,13 +35,12 @@ export class UserPasswordComponent extends FormReactive implements OnInit {
const userUpdate: UserUpdate = this.form.value const userUpdate: UserUpdate = this.form.value
this.userService.updateUser(this.userId, userUpdate).subscribe( this.userService.updateUser(this.userId, userUpdate)
() => { .subscribe({
this.notifier.success($localize`Password changed for user ${this.username}.`) next: () => this.notifier.success($localize`Password changed for user ${this.username}.`),
},
err => this.error = err.message error: err => this.error = err.message
) })
} }
togglePasswordVisibility () { togglePasswordVisibility () {

View File

@ -59,11 +59,12 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
this.paramsSub = this.route.params.subscribe(routeParams => { this.paramsSub = this.route.params.subscribe(routeParams => {
const userId = routeParams['id'] const userId = routeParams['id']
this.userService.getUser(userId, true).subscribe( this.userService.getUser(userId, true)
user => this.onUserFetched(user), .subscribe({
next: user => this.onUserFetched(user),
err => this.error = err.message error: err => this.error = err.message
) })
}) })
} }
@ -83,14 +84,15 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
if (userUpdate.pluginAuth === 'null') userUpdate.pluginAuth = null if (userUpdate.pluginAuth === 'null') userUpdate.pluginAuth = null
this.userService.updateUser(this.user.id, userUpdate).subscribe( this.userService.updateUser(this.user.id, userUpdate)
() => { .subscribe({
next: () => {
this.notifier.success($localize`User ${this.user.username} updated.`) this.notifier.success($localize`User ${this.user.username} updated.`)
this.router.navigate([ '/admin/users/list' ]) this.router.navigate([ '/admin/users/list' ])
}, },
err => this.error = err.message error: err => this.error = err.message
) })
} }
isCreation () { isCreation () {
@ -106,13 +108,14 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
} }
resetPassword () { resetPassword () {
this.userService.askResetPassword(this.user.email).subscribe( this.userService.askResetPassword(this.user.email)
() => { .subscribe({
next: () => {
this.notifier.success($localize`An email asking for password reset has been sent to ${this.user.username}.`) this.notifier.success($localize`An email asking for password reset has been sent to ${this.user.username}.`)
}, },
err => this.error = err.message error: err => this.error = err.message
) })
} }
private onUserFetched (userJson: UserType) { private onUserFetched (userJson: UserType) {

View File

@ -173,14 +173,14 @@ export class UserListComponent extends RestTable implements OnInit {
if (res === false) return if (res === false) return
this.userService.unbanUsers(users) this.userService.unbanUsers(users)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`${users.length} users unbanned.`) this.notifier.success($localize`${users.length} users unbanned.`)
this.reloadData() this.reloadData()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
async removeUsers (users: User[]) { async removeUsers (users: User[]) {
@ -195,25 +195,27 @@ export class UserListComponent extends RestTable implements OnInit {
const res = await this.confirmService.confirm(message, $localize`Delete`) const res = await this.confirmService.confirm(message, $localize`Delete`)
if (res === false) return if (res === false) return
this.userService.removeUser(users).subscribe( this.userService.removeUser(users)
() => { .subscribe({
next: () => {
this.notifier.success($localize`${users.length} users deleted.`) this.notifier.success($localize`${users.length} users deleted.`)
this.reloadData() this.reloadData()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
async setEmailsAsVerified (users: User[]) { async setEmailsAsVerified (users: User[]) {
this.userService.updateUsers(users, { emailVerified: true }).subscribe( this.userService.updateUsers(users, { emailVerified: true })
() => { .subscribe({
next: () => {
this.notifier.success($localize`${users.length} users email set as verified.`) this.notifier.success($localize`${users.length} users email set as verified.`)
this.reloadData() this.reloadData()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
isInSelectionMode () { isInSelectionMode () {
@ -227,13 +229,13 @@ export class UserListComponent extends RestTable implements OnInit {
pagination: this.pagination, pagination: this.pagination,
sort: this.sort, sort: this.sort,
search: this.search search: this.search
}).subscribe( }).subscribe({
resultList => { next: resultList => {
this.users = resultList.data this.users = resultList.data
this.totalRecords = resultList.total this.totalRecords = resultList.total
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -107,17 +107,17 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni
const { username, password } = this.form.value const { username, password } = this.form.value
this.authService.login(username, password) this.authService.login(username, password)
.subscribe( .subscribe({
() => this.redirectService.redirectToPreviousRoute(), next: () => this.redirectService.redirectToPreviousRoute(),
err => this.handleError(err) error: err => this.handleError(err)
) })
} }
askResetPassword () { askResetPassword () {
this.userService.askResetPassword(this.forgotPasswordEmail) this.userService.askResetPassword(this.forgotPasswordEmail)
.subscribe( .subscribe({
() => { next: () => {
const message = $localize`An email with the reset password instructions will be sent to ${this.forgotPasswordEmail}. const message = $localize`An email with the reset password instructions will be sent to ${this.forgotPasswordEmail}.
The link will expire within 1 hour.` The link will expire within 1 hour.`
@ -125,8 +125,8 @@ The link will expire within 1 hour.`
this.hideForgotPasswordModal() this.hideForgotPasswordModal()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
openForgotPasswordModal () { openForgotPasswordModal () {
@ -149,14 +149,14 @@ The link will expire within 1 hour.`
this.isAuthenticatedWithExternalAuth = true this.isAuthenticatedWithExternalAuth = true
this.authService.login(username, null, token) this.authService.login(username, null, token)
.subscribe( .subscribe({
() => this.redirectService.redirectToPreviousRoute(), next: () => this.redirectService.redirectToPreviousRoute(),
err => { error: err => {
this.handleError(err) this.handleError(err)
this.isAuthenticatedWithExternalAuth = false this.isAuthenticatedWithExternalAuth = false
} }
) })
} }
private handleError (err: any) { private handleError (err: any) {

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core' import { Component, OnInit } from '@angular/core'
import { AuthService, Notifier, ConfirmService, ScopedTokensService } from '@app/core' import { AuthService, ConfirmService, Notifier, ScopedTokensService } from '@app/core'
import { VideoService } from '@app/shared/shared-main' import { VideoService } from '@app/shared/shared-main'
import { FeedFormat } from '@shared/models' import { FeedFormat } from '@shared/models'
import { ScopedToken } from '@shared/models/users/user-scoped-token' import { ScopedToken } from '@shared/models/users/user-scoped-token'
@ -27,13 +27,11 @@ export class MyAccountApplicationsComponent implements OnInit {
ngOnInit () { ngOnInit () {
this.feedUrl = this.baseURL this.feedUrl = this.baseURL
this.scopedTokensService.getScopedTokens() this.scopedTokensService.getScopedTokens()
.subscribe( .subscribe({
tokens => this.regenApplications(tokens), next: tokens => this.regenApplications(tokens),
err => { error: err => this.notifier.error(err.message)
this.notifier.error(err.message) })
}
)
} }
async renewToken () { async renewToken () {
@ -43,17 +41,15 @@ export class MyAccountApplicationsComponent implements OnInit {
) )
if (res === false) return if (res === false) return
this.scopedTokensService.renewScopedTokens().subscribe( this.scopedTokensService.renewScopedTokens()
tokens => { .subscribe({
next: tokens => {
this.regenApplications(tokens) this.regenApplications(tokens)
this.notifier.success($localize`Token renewed. Update your client configuration accordingly.`) this.notifier.success($localize`Token renewed. Update your client configuration accordingly.`)
}, },
err => { error: err => this.notifier.error(err.message)
this.notifier.error(err.message) })
}
)
} }
private regenApplications (tokens: ScopedToken) { private regenApplications (tokens: ScopedToken) {

View File

@ -45,8 +45,8 @@ export class MyAccountChangeEmailComponent extends FormReactive implements OnIni
this.serverService.getConfig(), this.serverService.getConfig(),
this.userService.changeEmail(password, email) this.userService.changeEmail(password, email)
]).pipe(tap(() => this.authService.refreshUserInformation())) ]).pipe(tap(() => this.authService.refreshUserInformation()))
.subscribe( .subscribe({
([ config ]) => { next: ([ config ]) => {
this.form.reset() this.form.reset()
if (config.signup.requiresEmailVerification) { if (config.signup.requiresEmailVerification) {
@ -56,7 +56,7 @@ export class MyAccountChangeEmailComponent extends FormReactive implements OnIni
} }
}, },
err => { error: err => {
if (err.status === 401) { if (err.status === 401) {
this.error = $localize`You current password is invalid.` this.error = $localize`You current password is invalid.`
return return
@ -64,6 +64,6 @@ export class MyAccountChangeEmailComponent extends FormReactive implements OnIni
this.error = err.message this.error = err.message
} }
) })
} }
} }

View File

@ -43,15 +43,16 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On
const currentPassword = this.form.value[ 'current-password' ] const currentPassword = this.form.value[ 'current-password' ]
const newPassword = this.form.value[ 'new-password' ] const newPassword = this.form.value[ 'new-password' ]
this.userService.changePassword(currentPassword, newPassword).subscribe( this.userService.changePassword(currentPassword, newPassword)
() => { .subscribe({
next: () => {
this.notifier.success($localize`Password updated.`) this.notifier.success($localize`Password updated.`)
this.form.reset() this.form.reset()
this.error = null this.error = null
}, },
err => { error: err => {
if (err.status === 401) { if (err.status === 401) {
this.error = $localize`You current password is invalid.` this.error = $localize`You current password is invalid.`
return return
@ -59,6 +60,6 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On
this.error = err.message this.error = err.message
} }
) })
} }
} }

View File

@ -27,15 +27,16 @@ export class MyAccountDangerZoneComponent {
) )
if (res === false) return if (res === false) return
this.userService.deleteMe().subscribe( this.userService.deleteMe()
() => { .subscribe({
next: () => {
this.notifier.success($localize`Your account is deleted.`) this.notifier.success($localize`Your account is deleted.`)
this.authService.logout() this.authService.logout()
this.redirectService.redirectToHomepage() this.redirectService.redirectToHomepage()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -89,13 +89,13 @@ export class MyAccountNotificationPreferencesComponent implements OnInit {
private savePreferencesImpl () { private savePreferencesImpl () {
this.userNotificationService.updateNotificationSettings(this.user.notificationSettings) this.userNotificationService.updateNotificationSettings(this.user.notificationSettings)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Preferences saved`, undefined, 2000) this.notifier.success($localize`Preferences saved`, undefined, 2000)
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
private loadNotificationSettings () { private loadNotificationSettings () {

View File

@ -50,15 +50,16 @@ export class MyAccountProfileComponent extends FormReactive implements OnInit {
this.error = null this.error = null
this.userService.updateMyProfile({ displayName, description }).subscribe( this.userService.updateMyProfile({ displayName, description })
() => { .subscribe({
next: () => {
this.user.account.displayName = displayName this.user.account.displayName = displayName
this.user.account.description = description this.user.account.description = description
this.notifier.success($localize`Profile updated.`) this.notifier.success($localize`Profile updated.`)
}, },
err => this.error = err.message error: err => this.error = err.message
) })
} }
} }

View File

@ -39,31 +39,31 @@ export class MyAccountSettingsComponent implements OnInit, AfterViewChecked {
onAvatarChange (formData: FormData) { onAvatarChange (formData: FormData) {
this.userService.changeAvatar(formData) this.userService.changeAvatar(formData)
.subscribe( .subscribe({
data => { next: data => {
this.notifier.success($localize`Avatar changed.`) this.notifier.success($localize`Avatar changed.`)
this.user.updateAccountAvatar(data.avatar) this.user.updateAccountAvatar(data.avatar)
}, },
(err: HttpErrorResponse) => genericUploadErrorHandler({ error: (err: HttpErrorResponse) => genericUploadErrorHandler({
err, err,
name: $localize`avatar`, name: $localize`avatar`,
notifier: this.notifier notifier: this.notifier
}) })
) })
} }
onAvatarDelete () { onAvatarDelete () {
this.userService.deleteAvatar() this.userService.deleteAvatar()
.subscribe( .subscribe({
data => { next: data => {
this.notifier.success($localize`Avatar deleted.`) this.notifier.success($localize`Avatar deleted.`)
this.user.updateAccountAvatar() this.user.updateAccountAvatar()
}, },
(err: HttpErrorResponse) => this.notifier.error(err.message) error: (err: HttpErrorResponse) => this.notifier.error(err.message)
) })
} }
} }

View File

@ -59,15 +59,15 @@ export class MyVideoChannelCreateComponent extends MyVideoChannelEdit implements
.pipe( .pipe(
switchMap(() => this.uploadAvatar()), switchMap(() => this.uploadAvatar()),
switchMap(() => this.uploadBanner()) switchMap(() => this.uploadBanner())
).subscribe( ).subscribe({
() => { next: () => {
this.authService.refreshUserInformation() this.authService.refreshUserInformation()
this.notifier.success($localize`Video channel ${videoChannelCreate.displayName} created.`) this.notifier.success($localize`Video channel ${videoChannelCreate.displayName} created.`)
this.router.navigate(['/my-library', 'video-channels']) this.router.navigate(['/my-library', 'video-channels'])
}, },
err => { error: err => {
if (err.status === HttpStatusCode.CONFLICT_409) { if (err.status === HttpStatusCode.CONFLICT_409) {
this.error = $localize`This name already exists on this instance.` this.error = $localize`This name already exists on this instance.`
return return
@ -75,7 +75,7 @@ export class MyVideoChannelCreateComponent extends MyVideoChannelEdit implements
this.error = err.message this.error = err.message
} }
) })
} }
onAvatarChange (formData: FormData) { onAvatarChange (formData: FormData) {

View File

@ -52,8 +52,9 @@ export class MyVideoChannelUpdateComponent extends MyVideoChannelEdit implements
this.paramsSub = this.route.params.subscribe(routeParams => { this.paramsSub = this.route.params.subscribe(routeParams => {
const videoChannelId = routeParams['videoChannelId'] const videoChannelId = routeParams['videoChannelId']
this.videoChannelService.getVideoChannel(videoChannelId).subscribe( this.videoChannelService.getVideoChannel(videoChannelId)
videoChannelToUpdate => { .subscribe({
next: videoChannelToUpdate => {
this.videoChannel = videoChannelToUpdate this.videoChannel = videoChannelToUpdate
this.oldSupportField = videoChannelToUpdate.support this.oldSupportField = videoChannelToUpdate.support
@ -65,8 +66,8 @@ export class MyVideoChannelUpdateComponent extends MyVideoChannelEdit implements
}) })
}, },
err => this.error = err.message error: err => this.error = err.message
) })
}) })
} }
@ -85,8 +86,9 @@ export class MyVideoChannelUpdateComponent extends MyVideoChannelEdit implements
bulkVideosSupportUpdate: body.bulkVideosSupportUpdate || false bulkVideosSupportUpdate: body.bulkVideosSupportUpdate || false
} }
this.videoChannelService.updateVideoChannel(this.videoChannel.name, videoChannelUpdate).subscribe( this.videoChannelService.updateVideoChannel(this.videoChannel.name, videoChannelUpdate)
() => { .subscribe({
next: () => {
this.authService.refreshUserInformation() this.authService.refreshUserInformation()
this.notifier.success($localize`Video channel ${videoChannelUpdate.displayName} updated.`) this.notifier.success($localize`Video channel ${videoChannelUpdate.displayName} updated.`)
@ -94,68 +96,68 @@ export class MyVideoChannelUpdateComponent extends MyVideoChannelEdit implements
this.router.navigate([ '/my-library', 'video-channels' ]) this.router.navigate([ '/my-library', 'video-channels' ])
}, },
err => this.error = err.message error: err => this.error = err.message
) })
} }
onAvatarChange (formData: FormData) { onAvatarChange (formData: FormData) {
this.videoChannelService.changeVideoChannelImage(this.videoChannel.name, formData, 'avatar') this.videoChannelService.changeVideoChannelImage(this.videoChannel.name, formData, 'avatar')
.subscribe( .subscribe({
data => { next: data => {
this.notifier.success($localize`Avatar changed.`) this.notifier.success($localize`Avatar changed.`)
this.videoChannel.updateAvatar(data.avatar) this.videoChannel.updateAvatar(data.avatar)
}, },
(err: HttpErrorResponse) => genericUploadErrorHandler({ error: (err: HttpErrorResponse) => genericUploadErrorHandler({
err, err,
name: $localize`avatar`, name: $localize`avatar`,
notifier: this.notifier notifier: this.notifier
}) })
) })
} }
onAvatarDelete () { onAvatarDelete () {
this.videoChannelService.deleteVideoChannelImage(this.videoChannel.name, 'avatar') this.videoChannelService.deleteVideoChannelImage(this.videoChannel.name, 'avatar')
.subscribe( .subscribe({
data => { next: () => {
this.notifier.success($localize`Avatar deleted.`) this.notifier.success($localize`Avatar deleted.`)
this.videoChannel.resetAvatar() this.videoChannel.resetAvatar()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
onBannerChange (formData: FormData) { onBannerChange (formData: FormData) {
this.videoChannelService.changeVideoChannelImage(this.videoChannel.name, formData, 'banner') this.videoChannelService.changeVideoChannelImage(this.videoChannel.name, formData, 'banner')
.subscribe( .subscribe({
data => { next: data => {
this.notifier.success($localize`Banner changed.`) this.notifier.success($localize`Banner changed.`)
this.videoChannel.updateBanner(data.banner) this.videoChannel.updateBanner(data.banner)
}, },
(err: HttpErrorResponse) => genericUploadErrorHandler({ error: (err: HttpErrorResponse) => genericUploadErrorHandler({
err, err,
name: $localize`banner`, name: $localize`banner`,
notifier: this.notifier notifier: this.notifier
}) })
) })
} }
onBannerDelete () { onBannerDelete () {
this.videoChannelService.deleteVideoChannelImage(this.videoChannel.name, 'banner') this.videoChannelService.deleteVideoChannelImage(this.videoChannel.name, 'banner')
.subscribe( .subscribe({
data => { next: () => {
this.notifier.success($localize`Banner deleted.`) this.notifier.success($localize`Banner deleted.`)
this.videoChannel.resetBanner() this.videoChannel.resetBanner()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
get maxAvatarSize () { get maxAvatarSize () {

View File

@ -54,14 +54,14 @@ channel with the same name (${videoChannel.name})!`,
if (res === false) return if (res === false) return
this.videoChannelService.removeVideoChannel(videoChannel) this.videoChannelService.removeVideoChannel(videoChannel)
.subscribe( .subscribe({
() => { next: () => {
this.loadVideoChannels() this.loadVideoChannels()
this.notifier.success($localize`Video channel ${videoChannel.displayName} deleted.`) this.notifier.success($localize`Video channel ${videoChannel.displayName} deleted.`)
}, },
error => this.notifier.error(error.message) error: err => this.notifier.error(err.message)
) })
} }
private loadVideoChannels () { private loadVideoChannels () {

View File

@ -107,8 +107,8 @@ export class MyHistoryComponent implements OnInit, DisableForReuseHook {
onVideosHistoryChange () { onVideosHistoryChange () {
this.userService.updateMyProfile({ videosHistoryEnabled: this.videosHistoryEnabled }) this.userService.updateMyProfile({ videosHistoryEnabled: this.videosHistoryEnabled })
.subscribe( .subscribe({
() => { next: () => {
const message = this.videosHistoryEnabled === true ? const message = this.videosHistoryEnabled === true ?
$localize`Videos history is enabled` : $localize`Videos history is enabled` :
$localize`Videos history is disabled` $localize`Videos history is disabled`
@ -118,8 +118,8 @@ export class MyHistoryComponent implements OnInit, DisableForReuseHook {
this.authService.refreshUserInformation() this.authService.refreshUserInformation()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
async deleteHistory () { async deleteHistory () {
@ -130,14 +130,14 @@ export class MyHistoryComponent implements OnInit, DisableForReuseHook {
if (res !== true) return if (res !== true) return
this.userHistoryService.deleteUserVideosHistory() this.userHistoryService.deleteUserVideosHistory()
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Videos history deleted`) this.notifier.success($localize`Videos history deleted`)
this.reloadData() this.reloadData()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -64,14 +64,14 @@ export class MyAcceptOwnershipComponent extends FormReactive implements OnInit {
const videoChangeOwnership = this.videoChangeOwnership const videoChangeOwnership = this.videoChangeOwnership
this.videoOwnershipService this.videoOwnershipService
.acceptOwnership(videoChangeOwnership.id, { channelId: channel }) .acceptOwnership(videoChangeOwnership.id, { channelId: channel })
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Ownership accepted`) this.notifier.success($localize`Ownership accepted`)
if (this.accepted) this.accepted.emit() if (this.accepted) this.accepted.emit()
this.videoChangeOwnership = undefined this.videoChangeOwnership = undefined
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -53,16 +53,16 @@ export class MyOwnershipComponent extends RestTable implements OnInit {
refuse (videoChangeOwnership: VideoChangeOwnership) { refuse (videoChangeOwnership: VideoChangeOwnership) {
this.videoOwnershipService.refuseOwnership(videoChangeOwnership.id) this.videoOwnershipService.refuseOwnership(videoChangeOwnership.id)
.subscribe( .subscribe({
() => this.reloadData(), next: () => this.reloadData(),
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
protected reloadData () { protected reloadData () {
return this.videoOwnershipService.getOwnershipChanges(this.pagination, this.sort) return this.videoOwnershipService.getOwnershipChanges(this.pagination, this.sort)
.subscribe( .subscribe({
resultList => { next: resultList => {
this.videoChangeOwnerships = resultList.data.map(change => ({ this.videoChangeOwnerships = resultList.data.map(change => ({
...change, ...change,
initiatorAccount: new Account(change.initiatorAccount), initiatorAccount: new Account(change.initiatorAccount),
@ -71,7 +71,7 @@ export class MyOwnershipComponent extends RestTable implements OnInit {
this.totalRecords = resultList.total this.totalRecords = resultList.total
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -41,8 +41,8 @@ export class MySubscriptionsComponent {
private loadSubscriptions (more = true) { private loadSubscriptions (more = true) {
this.userSubscriptionService.listSubscriptions({ pagination: this.pagination, search: this.search }) this.userSubscriptionService.listSubscriptions({ pagination: this.pagination, search: this.search })
.subscribe( .subscribe({
res => { next: res => {
this.videoChannels = more this.videoChannels = more
? this.videoChannels.concat(res.data) ? this.videoChannels.concat(res.data)
: res.data : res.data
@ -51,7 +51,7 @@ export class MySubscriptionsComponent {
this.onDataSubject.next(res.data) this.onDataSubject.next(res.data)
}, },
error => this.notifier.error(error.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -64,13 +64,13 @@ export class MyVideoImportsComponent extends RestTable implements OnInit {
protected reloadData () { protected reloadData () {
this.videoImportService.getMyVideoImports(this.pagination, this.sort) this.videoImportService.getMyVideoImports(this.pagination, this.sort)
.subscribe( .subscribe({
resultList => { next: resultList => {
this.videoImports = resultList.data this.videoImports = resultList.data
this.totalRecords = resultList.total this.totalRecords = resultList.total
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -71,14 +71,15 @@ export class MyVideoPlaylistCreateComponent extends MyVideoPlaylistEdit implemen
thumbnailfile: body.thumbnailfile || null thumbnailfile: body.thumbnailfile || null
} }
this.videoPlaylistService.createVideoPlaylist(videoPlaylistCreate).subscribe( this.videoPlaylistService.createVideoPlaylist(videoPlaylistCreate)
() => { .subscribe({
next: () => {
this.notifier.success($localize`Playlist ${videoPlaylistCreate.displayName} created.`) this.notifier.success($localize`Playlist ${videoPlaylistCreate.displayName} created.`)
this.router.navigate([ '/my-library', 'video-playlists' ]) this.router.navigate([ '/my-library', 'video-playlists' ])
}, },
err => this.error = err.message error: err => this.error = err.message
) })
} }
isCreation () { isCreation () {

View File

@ -85,13 +85,13 @@ export class MyVideoPlaylistElementsComponent implements OnInit, OnDestroy {
this.playlistElements.splice(newIndex, 0, element) this.playlistElements.splice(newIndex, 0, element)
this.videoPlaylistService.reorderPlaylist(this.playlist.id, oldPosition, insertAfter) this.videoPlaylistService.reorderPlaylist(this.playlist.id, oldPosition, insertAfter)
.subscribe( .subscribe({
() => { next: () => {
this.reorderClientPositions() this.reorderClientPositions()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
onElementRemoved (element: VideoPlaylistElement) { onElementRemoved (element: VideoPlaylistElement) {
@ -129,14 +129,14 @@ export class MyVideoPlaylistElementsComponent implements OnInit, OnDestroy {
if (res === false) return if (res === false) return
this.videoPlaylistService.removeVideoPlaylist(videoPlaylist) this.videoPlaylistService.removeVideoPlaylist(videoPlaylist)
.subscribe( .subscribe({
() => { next: () => {
this.router.navigate([ '/my-library', 'video-playlists' ]) this.router.navigate([ '/my-library', 'video-playlists' ])
this.notifier.success($localize`Playlist ${videoPlaylist.displayName} deleted.`) this.notifier.success($localize`Playlist ${videoPlaylist.displayName} deleted.`)
}, },
error => this.notifier.error(error.message) error: err => this.notifier.error(err.message)
) })
} }
/** /**

View File

@ -64,16 +64,16 @@ export class MyVideoPlaylistUpdateComponent extends MyVideoPlaylistEdit implemen
]) ])
}) })
) )
.subscribe( .subscribe({
([ videoPlaylistToUpdate, videoPlaylistPrivacies]) => { next: ([ videoPlaylistToUpdate, videoPlaylistPrivacies]) => {
this.videoPlaylistToUpdate = videoPlaylistToUpdate this.videoPlaylistToUpdate = videoPlaylistToUpdate
this.videoPlaylistPrivacies = videoPlaylistPrivacies this.videoPlaylistPrivacies = videoPlaylistPrivacies
this.hydrateFormFromPlaylist() this.hydrateFormFromPlaylist()
}, },
err => this.error = err.message error: err => this.error = err.message
) })
} }
ngOnDestroy () { ngOnDestroy () {
@ -92,14 +92,15 @@ export class MyVideoPlaylistUpdateComponent extends MyVideoPlaylistEdit implemen
thumbnailfile: body.thumbnailfile || undefined thumbnailfile: body.thumbnailfile || undefined
} }
this.videoPlaylistService.updateVideoPlaylist(this.videoPlaylistToUpdate, videoPlaylistUpdate).subscribe( this.videoPlaylistService.updateVideoPlaylist(this.videoPlaylistToUpdate, videoPlaylistUpdate)
() => { .subscribe({
next: () => {
this.notifier.success($localize`Playlist ${videoPlaylistUpdate.displayName} updated.`) this.notifier.success($localize`Playlist ${videoPlaylistUpdate.displayName} updated.`)
this.router.navigate([ '/my-library', 'video-playlists' ]) this.router.navigate([ '/my-library', 'video-playlists' ])
}, },
err => this.error = err.message error: err => this.error = err.message
) })
} }
isCreation () { isCreation () {

View File

@ -37,16 +37,16 @@ export class MyVideoPlaylistsComponent {
if (res === false) return if (res === false) return
this.videoPlaylistService.removeVideoPlaylist(videoPlaylist) this.videoPlaylistService.removeVideoPlaylist(videoPlaylist)
.subscribe( .subscribe({
() => { next: () => {
this.videoPlaylists = this.videoPlaylists this.videoPlaylists = this.videoPlaylists
.filter(p => p.id !== videoPlaylist.id) .filter(p => p.id !== videoPlaylist.id)
this.notifier.success($localize`Playlist ${videoPlaylist.displayName}} deleted.`) this.notifier.success($localize`Playlist ${videoPlaylist.displayName}} deleted.`)
}, },
error => this.notifier.error(error.message) error: err => this.notifier.error(err.message)
) })
} }
isRegularPlaylist (playlist: VideoPlaylist) { isRegularPlaylist (playlist: VideoPlaylist) {

View File

@ -48,11 +48,11 @@ export class VideoChangeOwnershipComponent extends FormReactive implements OnIni
search (event: { query: string }) { search (event: { query: string }) {
const query = event.query const query = event.query
this.userService.autocomplete(query) this.userService.autocomplete(query)
.subscribe( .subscribe({
usernames => this.usernamePropositions = usernames, next: usernames => this.usernamePropositions = usernames,
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
changeOwnership () { changeOwnership () {
@ -60,10 +60,10 @@ export class VideoChangeOwnershipComponent extends FormReactive implements OnIni
this.videoOwnershipService this.videoOwnershipService
.changeOwnership(this.video.id, username) .changeOwnership(this.video.id, username)
.subscribe( .subscribe({
() => this.notifier.success($localize`Ownership change request sent.`), next: () => this.notifier.success($localize`Ownership change request sent.`),
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -126,14 +126,14 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook {
concat(...observables) concat(...observables)
.pipe(toArray()) .pipe(toArray())
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`${toDeleteVideosIds.length} videos deleted.`) this.notifier.success($localize`${toDeleteVideosIds.length} videos deleted.`)
this.selection = {} this.selection = {}
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
async deleteVideo (video: Video) { async deleteVideo (video: Video) {
@ -144,14 +144,14 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook {
if (res === false) return if (res === false) return
this.videoService.removeVideo(video.id) this.videoService.removeVideo(video.id)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Video ${video.name} deleted.`) this.notifier.success($localize`Video ${video.name} deleted.`)
this.removeVideoFromArray(video.id) this.removeVideoFromArray(video.id)
}, },
error => this.notifier.error(error.message) error: err => this.notifier.error(err.message)
) })
} }
changeOwnership (video: Video) { changeOwnership (video: Video) {

View File

@ -42,14 +42,14 @@ export class ResetPasswordComponent extends FormReactive implements OnInit {
resetPassword () { resetPassword () {
this.userService.resetPassword(this.userId, this.verificationString, this.form.value.password) this.userService.resetPassword(this.userId, this.verificationString, this.form.value.password)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Your password has been successfully reset!`) this.notifier.success($localize`Your password has been successfully reset!`)
this.router.navigate([ '/login' ]) this.router.navigate([ '/login' ])
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
isConfirmedPasswordValid () { isConfirmedPasswordValid () {

View File

@ -73,8 +73,9 @@ export class SearchComponent implements OnInit, OnDestroy {
ngOnInit () { ngOnInit () {
this.serverConfig = this.serverService.getHTMLConfig() this.serverConfig = this.serverService.getHTMLConfig()
this.subActivatedRoute = this.route.queryParams.subscribe( this.subActivatedRoute = this.route.queryParams
async queryParams => { .subscribe({
next: async queryParams => {
const querySearch = queryParams['search'] const querySearch = queryParams['search']
const searchTarget = queryParams['searchTarget'] const searchTarget = queryParams['searchTarget']
@ -101,8 +102,8 @@ export class SearchComponent implements OnInit, OnDestroy {
this.search() this.search()
}, },
err => this.notifier.error(err.text) error: err => this.notifier.error(err.text)
) })
this.userService.getAnonymousOrLoggedUser() this.userService.getAnonymousOrLoggedUser()
.subscribe(user => this.userMiniature = user) .subscribe(user => this.userMiniature = user)
@ -140,7 +141,8 @@ export class SearchComponent implements OnInit, OnDestroy {
this.getVideoChannelObs(), this.getVideoChannelObs(),
this.getVideoPlaylistObs(), this.getVideoPlaylistObs(),
this.getVideosObs() this.getVideosObs()
]).subscribe(results => { ]).subscribe({
next: results => {
for (const result of results) { for (const result of results) {
this.results = this.results.concat(result.data) this.results = this.results.concat(result.data)
} }
@ -151,7 +153,7 @@ export class SearchComponent implements OnInit, OnDestroy {
this.hasMoreResults = this.results.length < this.pagination.totalItems this.hasMoreResults = this.results.length < this.pagination.totalItems
}, },
err => { error: err => {
if (this.advancedSearch.searchTarget !== 'search-index') { if (this.advancedSearch.searchTarget !== 'search-index') {
this.notifier.error(err.message) this.notifier.error(err.message)
return return
@ -165,8 +167,9 @@ export class SearchComponent implements OnInit, OnDestroy {
this.search() this.search()
}, },
() => { complete: () => {
this.isSearching = false this.isSearching = false
}
}) })
} }

View File

@ -122,8 +122,8 @@ export class RegisterComponent implements OnInit {
'filter:api.signup.registration.create.params' 'filter:api.signup.registration.create.params'
) )
this.userService.signup(body).subscribe( this.userService.signup(body).subscribe({
() => { next: () => {
this.signupDone = true this.signupDone = true
if (this.requiresEmailVerification) { if (this.requiresEmailVerification) {
@ -133,16 +133,16 @@ export class RegisterComponent implements OnInit {
// Auto login // Auto login
this.authService.login(body.username, body.password) this.authService.login(body.username, body.password)
.subscribe( .subscribe({
() => { next: () => {
this.success = $localize`You are now logged in as ${body.username}!` this.success = $localize`You are now logged in as ${body.username}!`
}, },
err => this.error = err.message error: err => this.error = err.message
) })
}, },
err => this.error = err.message error: err => this.error = err.message
) })
} }
} }

View File

@ -34,15 +34,13 @@ export class VerifyAccountAskSendEmailComponent extends FormReactive implements
askSendVerifyEmail () { askSendVerifyEmail () {
const email = this.form.value['verify-email-email'] const email = this.form.value['verify-email-email']
this.userService.askSendVerifyEmail(email) this.userService.askSendVerifyEmail(email)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`An email with verification link will be sent to ${email}.`) this.notifier.success($localize`An email with verification link will be sent to ${email}.`)
this.redirectService.redirectToHomepage() this.redirectService.redirectToHomepage()
}, },
err => { error: err => this.notifier.error(err.message)
this.notifier.error(err.message) })
}
)
} }
} }

View File

@ -38,8 +38,8 @@ export class VerifyAccountEmailComponent implements OnInit {
verifyEmail () { verifyEmail () {
this.userService.verifyEmail(this.userId, this.verificationString, this.isPendingEmail) this.userService.verifyEmail(this.userId, this.verificationString, this.isPendingEmail)
.subscribe( .subscribe({
() => { next: () => {
if (this.authService.isLoggedIn()) { if (this.authService.isLoggedIn()) {
this.authService.refreshUserInformation() this.authService.refreshUserInformation()
} }
@ -47,11 +47,11 @@ export class VerifyAccountEmailComponent implements OnInit {
this.success = true this.success = true
}, },
err => { error: err => {
this.failed = true this.failed = true
this.notifier.error(err.message) this.notifier.error(err.message)
} }
) })
} }
} }

View File

@ -8,7 +8,7 @@ import { FormValidatorService } from '@app/shared/shared-forms'
import { Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' import { Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main'
import { LiveVideoService } from '@app/shared/shared-video-live' import { LiveVideoService } from '@app/shared/shared-video-live'
import { LoadingBarService } from '@ngx-loading-bar/core' import { LoadingBarService } from '@ngx-loading-bar/core'
import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, PeerTubeProblemDocument, ServerErrorCode, VideoPrivacy } from '@shared/models' import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, PeerTubeProblemDocument, ServerErrorCode } from '@shared/models'
import { VideoSend } from './video-send' import { VideoSend } from './video-send'
@Component({ @Component({
@ -74,8 +74,9 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView
const toPatch = Object.assign({}, video, { privacy: this.firstStepPrivacyId }) const toPatch = Object.assign({}, video, { privacy: this.firstStepPrivacyId })
this.form.patchValue(toPatch) this.form.patchValue(toPatch)
this.liveVideoService.goLive(video).subscribe( this.liveVideoService.goLive(video)
res => { .subscribe({
next: res => {
this.videoId = res.video.id this.videoId = res.video.id
this.videoUUID = res.video.uuid this.videoUUID = res.video.uuid
this.isInUpdateForm = true this.isInUpdateForm = true
@ -85,7 +86,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView
this.fetchVideoLive() this.fetchVideoLive()
}, },
err => { error: err => {
this.firstStepError.emit() this.firstStepError.emit()
let message = err.message let message = err.message
@ -100,7 +101,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView
this.notifier.error(message) this.notifier.error(message)
} }
) })
} }
updateSecondStep () { updateSecondStep () {
@ -123,19 +124,19 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView
this.updateVideoAndCaptions(video), this.updateVideoAndCaptions(video),
this.liveVideoService.updateLive(this.videoId, liveVideoUpdate) this.liveVideoService.updateLive(this.videoId, liveVideoUpdate)
]).subscribe( ]).subscribe({
() => { next: () => {
this.notifier.success($localize`Live published.`) this.notifier.success($localize`Live published.`)
this.router.navigateByUrl(Video.buildWatchUrl(video)) this.router.navigateByUrl(Video.buildWatchUrl(video))
}, },
err => { error: err => {
this.error = err.message this.error = err.message
scrollToTop() scrollToTop()
console.error(err) console.error(err)
} }
) })
} }
getMaxLiveDuration () { getMaxLiveDuration () {
@ -148,15 +149,15 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView
private fetchVideoLive () { private fetchVideoLive () {
this.liveVideoService.getVideoLive(this.videoId) this.liveVideoService.getVideoLive(this.videoId)
.subscribe( .subscribe({
liveVideo => { next: liveVideo => {
this.liveVideo = liveVideo this.liveVideo = liveVideo
}, },
err => { error: err => {
this.firstStepError.emit() this.firstStepError.emit()
this.notifier.error(err.message) this.notifier.error(err.message)
} }
) })
} }
} }

View File

@ -88,8 +88,9 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af
this.loadingBar.useRef().start() this.loadingBar.useRef().start()
this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate).subscribe( this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate)
res => { .subscribe({
next: res => {
this.loadingBar.useRef().complete() this.loadingBar.useRef().complete()
this.firstStepDone.emit(res.video.name) this.firstStepDone.emit(res.video.name)
this.isImportingVideo = false this.isImportingVideo = false
@ -107,7 +108,7 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af
hydrateFormFromVideo(this.form, this.video, false) hydrateFormFromVideo(this.form, this.video, false)
}, },
err => { error: err => {
this.loadingBar.useRef().complete() this.loadingBar.useRef().complete()
this.isImportingVideo = false this.isImportingVideo = false
this.firstStepError.emit() this.firstStepError.emit()
@ -121,7 +122,7 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af
this.notifier.error(message) this.notifier.error(message)
} }
) })
} }
updateSecondStep () { updateSecondStep () {
@ -135,19 +136,19 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af
// Update the video // Update the video
this.updateVideoAndCaptions(this.video) this.updateVideoAndCaptions(this.video)
.subscribe( .subscribe({
() => { next: () => {
this.isUpdatingVideo = false this.isUpdatingVideo = false
this.notifier.success($localize`Video to import updated.`) this.notifier.success($localize`Video to import updated.`)
this.router.navigate([ '/my-library', 'video-imports' ]) this.router.navigate([ '/my-library', 'video-imports' ])
}, },
err => { error: err => {
this.error = err.message this.error = err.message
scrollToTop() scrollToTop()
console.error(err) console.error(err)
} }
) })
} }
} }

View File

@ -6,7 +6,7 @@ import { getAbsoluteAPIUrl, scrollToTop } from '@app/helpers'
import { FormValidatorService } from '@app/shared/shared-forms' import { FormValidatorService } from '@app/shared/shared-forms'
import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main' import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main'
import { LoadingBarService } from '@ngx-loading-bar/core' import { LoadingBarService } from '@ngx-loading-bar/core'
import { VideoPrivacy, VideoUpdate } from '@shared/models' import { VideoUpdate } from '@shared/models'
import { hydrateFormFromVideo } from '../shared/video-edit-utils' import { hydrateFormFromVideo } from '../shared/video-edit-utils'
import { VideoSend } from './video-send' import { VideoSend } from './video-send'
@ -86,8 +86,8 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV
) )
}) })
) )
.subscribe( .subscribe({
({ video, videoCaptions }) => { next: ({ video, videoCaptions }) => {
this.loadingBar.useRef().complete() this.loadingBar.useRef().complete()
this.firstStepDone.emit(video.name) this.firstStepDone.emit(video.name)
this.isImportingVideo = false this.isImportingVideo = false
@ -117,13 +117,13 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV
hydrateFormFromVideo(this.form, this.video, true) hydrateFormFromVideo(this.form, this.video, true)
}, },
err => { error: err => {
this.loadingBar.useRef().complete() this.loadingBar.useRef().complete()
this.isImportingVideo = false this.isImportingVideo = false
this.firstStepError.emit() this.firstStepError.emit()
this.notifier.error(err.message) this.notifier.error(err.message)
} }
) })
} }
updateSecondStep () { updateSecondStep () {
@ -137,19 +137,19 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV
// Update the video // Update the video
this.updateVideoAndCaptions(this.video) this.updateVideoAndCaptions(this.video)
.subscribe( .subscribe({
() => { next: () => {
this.isUpdatingVideo = false this.isUpdatingVideo = false
this.notifier.success($localize`Video to import updated.`) this.notifier.success($localize`Video to import updated.`)
this.router.navigate([ '/my-library', 'video-imports' ]) this.router.navigate([ '/my-library', 'video-imports' ])
}, },
err => { error: err => {
this.error = err.message this.error = err.message
scrollToTop() scrollToTop()
console.error(err) console.error(err)
} }
) })
} }
} }

View File

@ -240,8 +240,8 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
this.isUpdatingVideo = true this.isUpdatingVideo = true
this.updateVideoAndCaptions(video) this.updateVideoAndCaptions(video)
.subscribe( .subscribe({
() => { next: () => {
this.isUpdatingVideo = false this.isUpdatingVideo = false
this.isUploadingVideo = false this.isUploadingVideo = false
@ -249,12 +249,12 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
this.router.navigateByUrl(Video.buildWatchUrl(video)) this.router.navigateByUrl(Video.buildWatchUrl(video))
}, },
err => { error: err => {
this.error = err.message this.error = err.message
scrollToTop() scrollToTop()
console.error(err) console.error(err)
} }
) })
} }
private getInputVideoFile () { private getInputVideoFile () {

View File

@ -47,7 +47,8 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
this.route.data this.route.data
.pipe(map(data => data.videoData)) .pipe(map(data => data.videoData))
.subscribe(({ video, videoChannels, videoCaptions, liveVideo }) => { .subscribe({
next: ({ video, videoChannels, videoCaptions, liveVideo }) => {
this.video = new VideoEdit(video) this.video = new VideoEdit(video)
this.videoDetails = video this.videoDetails = video
@ -70,11 +71,11 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
}) })
}, },
err => { error: err => {
console.error(err) console.error(err)
this.notifier.error(err.message) this.notifier.error(err.message)
} }
) })
} }
@HostListener('window:beforeunload', [ '$event' ]) @HostListener('window:beforeunload', [ '$event' ])
@ -150,8 +151,8 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
return this.liveVideoService.updateLive(this.video.id, liveVideoUpdate) return this.liveVideoService.updateLive(this.video.id, liveVideoUpdate)
}) })
) )
.subscribe( .subscribe({
() => { next: () => {
this.updateDone = true this.updateDone = true
this.isUpdatingVideo = false this.isUpdatingVideo = false
this.loadingBar.useRef().complete() this.loadingBar.useRef().complete()
@ -159,13 +160,13 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
this.router.navigateByUrl(Video.buildWatchUrl(this.video)) this.router.navigateByUrl(Video.buildWatchUrl(this.video))
}, },
err => { error: err => {
this.loadingBar.useRef().complete() this.loadingBar.useRef().complete()
this.isUpdatingVideo = false this.isUpdatingVideo = false
this.notifier.error(err.message) this.notifier.error(err.message)
console.error(err) console.error(err)
} }
) })
} }
hydratePluginFieldsFromVideo () { hydratePluginFieldsFromVideo () {

View File

@ -90,16 +90,16 @@ export class VideoRateComponent implements OnInit, OnChanges, OnDestroy {
if (this.isUserLoggedIn === false) return if (this.isUserLoggedIn === false) return
this.videoService.getUserVideoRating(this.video.id) this.videoService.getUserVideoRating(this.video.id)
.subscribe( .subscribe({
ratingObject => { next: ratingObject => {
if (!ratingObject) return if (!ratingObject) return
this.userRating = ratingObject.rating this.userRating = ratingObject.rating
this.userRatingLoaded.emit(this.userRating) this.userRatingLoaded.emit(this.userRating)
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
private setRating (nextRating: UserVideoRateType) { private setRating (nextRating: UserVideoRateType) {
@ -110,16 +110,16 @@ export class VideoRateComponent implements OnInit, OnChanges, OnDestroy {
} }
ratingMethods[nextRating].call(this.videoService, this.video.id) ratingMethods[nextRating].call(this.videoService, this.video.id)
.subscribe( .subscribe({
() => { next: () => {
// Update the video like attribute // Update the video like attribute
this.updateVideoRating(this.userRating, nextRating) this.updateVideoRating(this.userRating, nextRating)
this.userRating = nextRating this.userRating = nextRating
this.rateUpdated.emit(this.userRating) this.rateUpdated.emit(this.userRating)
}, },
(err: { message: string }) => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
private updateVideoRating (oldRating: UserVideoRateType, newRating: UserVideoRateType) { private updateVideoRating (oldRating: UserVideoRateType, newRating: UserVideoRateType) {

View File

@ -137,19 +137,19 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges,
obs = this.addCommentThread(commentCreate) obs = this.addCommentThread(commentCreate)
} }
obs.subscribe( obs.subscribe({
comment => { next: comment => {
this.addingComment = false this.addingComment = false
this.commentCreated.emit(comment) this.commentCreated.emit(comment)
this.form.reset() this.form.reset()
}, },
err => { error: err => {
this.addingComment = false this.addingComment = false
this.notifier.error(err.text) this.notifier.error(err.text)
} }
) })
} }
isAddButtonDisplayed () { isAddButtonDisplayed () {

View File

@ -149,11 +149,11 @@ export class VideoCommentComponent implements OnInit, OnChanges {
const user = this.authService.getUser() const user = this.authService.getUser()
if (user.hasRight(UserRight.MANAGE_USERS)) { if (user.hasRight(UserRight.MANAGE_USERS)) {
this.userService.getUserWithCache(account.userId) this.userService.getUserWithCache(account.userId)
.subscribe( .subscribe({
user => this.commentUser = user, next: user => this.commentUser = user,
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -90,8 +90,8 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
'filter:api.video-watch.video-thread-replies.list.result' 'filter:api.video-watch.video-thread-replies.list.result'
) )
obs.subscribe( obs.subscribe({
res => { next: res => {
this.threadComments[commentId] = res this.threadComments[commentId] = res
this.threadLoading[commentId] = false this.threadLoading[commentId] = false
this.hooks.runAction('action:video-watch.video-thread-replies.loaded', 'video-watch', { data: res }) this.hooks.runAction('action:video-watch.video-thread-replies.loaded', 'video-watch', { data: res })
@ -104,8 +104,8 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
} }
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
loadMoreThreads () { loadMoreThreads () {
@ -123,8 +123,8 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
'filter:api.video-watch.video-threads.list.result' 'filter:api.video-watch.video-threads.list.result'
) )
obs.subscribe( obs.subscribe({
res => { next: res => {
this.comments = this.comments.concat(res.data) this.comments = this.comments.concat(res.data)
this.componentPagination.totalItems = res.total this.componentPagination.totalItems = res.total
this.totalNotDeletedComments = res.totalNotDeletedComments this.totalNotDeletedComments = res.totalNotDeletedComments
@ -133,8 +133,8 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
this.hooks.runAction('action:video-watch.video-threads.loaded', 'video-watch', { data: this.componentPagination }) this.hooks.runAction('action:video-watch.video-threads.loaded', 'video-watch', { data: this.componentPagination })
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
onCommentThreadCreated (comment: VideoComment) { onCommentThreadCreated (comment: VideoComment) {
@ -181,8 +181,8 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
if (res === false) return false if (res === false) return false
this.videoCommentService.deleteVideoComment(commentToDelete.videoId, commentToDelete.id) this.videoCommentService.deleteVideoComment(commentToDelete.videoId, commentToDelete.id)
.subscribe( .subscribe({
() => { next: () => {
if (this.highlightedThread?.id === commentToDelete.id) { if (this.highlightedThread?.id === commentToDelete.id) {
commentToDelete = this.comments.find(c => c.id === commentToDelete.id) commentToDelete = this.comments.find(c => c.id === commentToDelete.id)
@ -193,8 +193,8 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
this.softDeleteComment(commentToDelete) this.softDeleteComment(commentToDelete)
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
return true return true
} }

View File

@ -50,8 +50,8 @@ export class VideoDescriptionComponent implements OnChanges {
this.descriptionLoading = true this.descriptionLoading = true
this.videoService.loadCompleteDescription(this.video.descriptionPath) this.videoService.loadCompleteDescription(this.video.descriptionPath)
.subscribe( .subscribe({
description => { next: description => {
this.completeDescriptionShown = true this.completeDescriptionShown = true
this.descriptionLoading = false this.descriptionLoading = false
@ -61,11 +61,11 @@ export class VideoDescriptionComponent implements OnChanges {
this.updateVideoDescription(this.completeVideoDescription) this.updateVideoDescription(this.completeVideoDescription)
}, },
error => { error: err => {
this.descriptionLoading = false this.descriptionLoading = false
this.notifier.error(error.message) this.notifier.error(err.message)
} }
) })
} }
onTimestampClicked (timestamp: number) { onTimestampClicked (timestamp: number) {

View File

@ -1,4 +1,3 @@
import { Component, EventEmitter, Input, Output } from '@angular/core' import { Component, EventEmitter, Input, Output } from '@angular/core'
import { Router } from '@angular/router' import { Router } from '@angular/router'
import { AuthService, ComponentPagination, LocalStorageService, Notifier, SessionStorageService, UserService } from '@app/core' import { AuthService, ComponentPagination, LocalStorageService, Notifier, SessionStorageService, UserService } from '@app/core'
@ -196,12 +195,14 @@ export class VideoWatchPlaylistComponent {
autoPlayNextVideoPlaylist: this.autoPlayNextVideoPlaylist autoPlayNextVideoPlaylist: this.autoPlayNextVideoPlaylist
} }
this.userService.updateMyProfile(details).subscribe( this.userService.updateMyProfile(details)
() => { .subscribe({
next: () => {
this.auth.refreshUserInformation() this.auth.refreshUserInformation()
}, },
err => this.notifier.error(err.message)
) error: err => this.notifier.error(err.message)
})
} }
} }

View File

@ -84,12 +84,14 @@ export class RecommendedVideosComponent implements OnInit, OnChanges {
autoPlayNextVideo: this.autoPlayNextVideo autoPlayNextVideo: this.autoPlayNextVideo
} }
this.userService.updateMyProfile(details).subscribe( this.userService.updateMyProfile(details)
() => { .subscribe({
next: () => {
this.authService.refreshUserInformation() this.authService.refreshUserInformation()
}, },
err => this.notifier.error(err.message)
) error: err => this.notifier.error(err.message)
})
} }
} }
} }

View File

@ -238,8 +238,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
) )
forkJoin([ videoObs, this.videoCaptionService.listCaptions(videoId)]) forkJoin([ videoObs, this.videoCaptionService.listCaptions(videoId)])
.subscribe( .subscribe({
([ video, captionsResult ]) => { next: ([ video, captionsResult ]) => {
const queryParams = this.route.snapshot.queryParams const queryParams = this.route.snapshot.queryParams
const urlOptions = { const urlOptions = {
@ -260,23 +260,23 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
.catch(err => this.handleGlobalError(err)) .catch(err => this.handleGlobalError(err))
}, },
err => this.handleRequestError(err) error: err => this.handleRequestError(err)
) })
} }
private loadPlaylist (playlistId: string) { private loadPlaylist (playlistId: string) {
if (this.isSameElement(this.playlist, playlistId)) return if (this.isSameElement(this.playlist, playlistId)) return
this.playlistService.getVideoPlaylist(playlistId) this.playlistService.getVideoPlaylist(playlistId)
.subscribe( .subscribe({
playlist => { next: playlist => {
this.playlist = playlist this.playlist = playlist
this.videoWatchPlaylist.loadPlaylistElements(playlist, !this.playlistPosition, this.playlistPosition) this.videoWatchPlaylist.loadPlaylistElements(playlist, !this.playlistPosition, this.playlistPosition)
}, },
err => this.handleRequestError(err) error: err => this.handleRequestError(err)
) })
} }
private isSameElement (element: VideoDetails | VideoPlaylist, newId: string) { private isSameElement (element: VideoDetails | VideoPlaylist, newId: string) {

View File

@ -68,8 +68,8 @@ export class VideoOverviewComponent implements OnInit {
this.isLoading = true this.isLoading = true
this.overviewService.getVideosOverview(this.currentPage) this.overviewService.getVideosOverview(this.currentPage)
.subscribe( .subscribe({
overview => { next: overview => {
this.isLoading = false this.isLoading = false
if (overview.tags.length === 0 && overview.channels.length === 0 && overview.categories.length === 0) { if (overview.tags.length === 0 && overview.channels.length === 0 && overview.categories.length === 0) {
@ -85,10 +85,10 @@ export class VideoOverviewComponent implements OnInit {
this.overviews.push(overview) this.overviews.push(overview)
}, },
err => { error: err => {
this.notifier.error(err.message) this.notifier.error(err.message)
this.isLoading = false this.isLoading = false
} }
) })
} }
} }

View File

@ -56,8 +56,8 @@ export class VideoUserSubscriptionsComponent extends AbstractVideoList implement
this.authService.userInformationLoaded this.authService.userInformationLoaded
.pipe(switchMap(() => this.scopedTokensService.getScopedTokens())) .pipe(switchMap(() => this.scopedTokensService.getScopedTokens()))
.subscribe( .subscribe({
tokens => { next: tokens => {
const feeds = this.videoService.getVideoSubscriptionFeedUrls(user.account.id, tokens.feedToken) const feeds = this.videoService.getVideoSubscriptionFeedUrls(user.account.id, tokens.feedToken)
feedUrl = feedUrl + feeds.find(f => f.format === FeedFormat.RSS).url feedUrl = feedUrl + feeds.find(f => f.format === FeedFormat.RSS).url
@ -74,10 +74,10 @@ export class VideoUserSubscriptionsComponent extends AbstractVideoList implement
}) })
}, },
err => { error: err => {
this.notifier.error(err.message) this.notifier.error(err.message)
} }
) })
} }
ngOnDestroy () { ngOnDestroy () {

View File

@ -80,8 +80,8 @@ export class AuthService {
// Fetch the client_id/client_secret // Fetch the client_id/client_secret
this.http.get<OAuthClientLocal>(AuthService.BASE_CLIENT_URL) this.http.get<OAuthClientLocal>(AuthService.BASE_CLIENT_URL)
.pipe(catchError(res => this.restExtractor.handleError(res))) .pipe(catchError(res => this.restExtractor.handleError(res)))
.subscribe( .subscribe({
res => { next: res => {
this.clientId = res.client_id this.clientId = res.client_id
this.clientSecret = res.client_secret this.clientSecret = res.client_secret
@ -91,18 +91,18 @@ export class AuthService {
console.log('Client credentials loaded.') console.log('Client credentials loaded.')
}, },
error => { error: err => {
let errorMessage = error.message let errorMessage = err.message
if (error.status === HttpStatusCode.FORBIDDEN_403) { if (err.status === HttpStatusCode.FORBIDDEN_403) {
errorMessage = $localize`Cannot retrieve OAuth Client credentials: ${error.text}. errorMessage = $localize`Cannot retrieve OAuth Client credentials: ${err.text}.
Ensure you have correctly configured PeerTube (config/ directory), in particular the "webserver" section.` Ensure you have correctly configured PeerTube (config/ directory), in particular the "webserver" section.`
} }
// We put a bigger timeout: this is an important message // We put a bigger timeout: this is an important message
this.notifier.error(errorMessage, $localize`Error`, 7000) this.notifier.error(errorMessage, $localize`Error`, 7000)
} }
) })
} }
getRefreshToken () { getRefreshToken () {
@ -168,15 +168,15 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular
const headers = new HttpHeaders().set('Authorization', authHeaderValue) const headers = new HttpHeaders().set('Authorization', authHeaderValue)
this.http.post<{ redirectUrl?: string }>(AuthService.BASE_REVOKE_TOKEN_URL, {}, { headers }) this.http.post<{ redirectUrl?: string }>(AuthService.BASE_REVOKE_TOKEN_URL, {}, { headers })
.subscribe( .subscribe({
res => { next: res => {
if (res.redirectUrl) { if (res.redirectUrl) {
window.location.href = res.redirectUrl window.location.href = res.redirectUrl
} }
}, },
err => console.error(err) error: err => console.error(err)
) })
this.user = null this.user = null
@ -215,9 +215,9 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular
this.logout() this.logout()
this.router.navigate([ '/login' ]) this.router.navigate([ '/login' ])
return observableThrowError({ return observableThrowError(() => ({
error: $localize`You need to reconnect.` error: $localize`You need to reconnect.`
}) }))
}), }),
share() share()
) )
@ -234,14 +234,14 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular
} }
this.mergeUserInformation(obj) this.mergeUserInformation(obj)
.subscribe( .subscribe({
res => { next: res => {
this.user.patch(res) this.user.patch(res)
this.user.save() this.user.save()
this.userInformationLoaded.next(true) this.userInformationLoaded.next(true)
} }
) })
} }
private mergeUserInformation (obj: UserLoginWithUsername): Observable<UserLoginWithUserInformation> { private mergeUserInformation (obj: UserLoginWithUsername): Observable<UserLoginWithUserInformation> {

View File

@ -1,6 +1,5 @@
import { first } from 'rxjs/operators' import { firstValueFrom, Subject } from 'rxjs'
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { Subject } from 'rxjs'
type ConfirmOptions = { type ConfirmOptions = {
title: string title: string
@ -18,16 +17,12 @@ export class ConfirmService {
confirm (message: string, title = '', confirmButtonText?: string) { confirm (message: string, title = '', confirmButtonText?: string) {
this.showConfirm.next({ title, message, confirmButtonText }) this.showConfirm.next({ title, message, confirmButtonText })
return this.confirmResponse.asObservable() return firstValueFrom(this.confirmResponse.asObservable())
.pipe(first())
.toPromise()
} }
confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '', confirmButtonText?: string) { confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '', confirmButtonText?: string) {
this.showConfirm.next({ title, message, inputLabel, expectedInputValue, confirmButtonText }) this.showConfirm.next({ title, message, inputLabel, expectedInputValue, confirmButtonText })
return this.confirmResponse.asObservable() return firstValueFrom(this.confirmResponse.asObservable())
.pipe(first())
.toPromise()
} }
} }

View File

@ -1,4 +1,4 @@
import { Observable, of } from 'rxjs' import { firstValueFrom, Observable, of } from 'rxjs'
import { catchError, map, shareReplay } from 'rxjs/operators' import { catchError, map, shareReplay } from 'rxjs/operators'
import { HttpClient } from '@angular/common/http' import { HttpClient } from '@angular/common/http'
import { Inject, Injectable, LOCALE_ID, NgZone } from '@angular/core' import { Inject, Injectable, LOCALE_ID, NgZone } from '@angular/core'
@ -164,18 +164,20 @@ export class PluginService implements ClientHook {
getSettings: () => { getSettings: () => {
const path = PluginService.BASE_PLUGIN_API_URL + '/' + npmName + '/public-settings' const path = PluginService.BASE_PLUGIN_API_URL + '/' + npmName + '/public-settings'
return this.authHttp.get<PublicServerSetting>(path) const obs = this.authHttp.get<PublicServerSetting>(path)
.pipe( .pipe(
map(p => p.publicSettings), map(p => p.publicSettings),
catchError(res => this.restExtractor.handleError(res)) catchError(res => this.restExtractor.handleError(res))
) )
.toPromise()
return firstValueFrom(obs)
}, },
getServerConfig: () => { getServerConfig: () => {
return this.server.getConfig() const obs = this.server.getConfig()
.pipe(catchError(res => this.restExtractor.handleError(res))) .pipe(catchError(res => this.restExtractor.handleError(res)))
.toPromise()
return firstValueFrom(obs)
}, },
isLoggedIn: () => { isLoggedIn: () => {
@ -216,10 +218,11 @@ export class PluginService implements ClientHook {
}, },
translate: (value: string) => { translate: (value: string) => {
return this.translationsObservable const obs = this.translationsObservable
.pipe(map(allTranslations => allTranslations[npmName])) .pipe(map(allTranslations => allTranslations[npmName]))
.pipe(map(translations => peertubeTranslate(value, translations))) .pipe(map(translations => peertubeTranslate(value, translations)))
.toPromise()
return firstValueFrom(obs)
} }
} }
} }

View File

@ -89,7 +89,7 @@ export class RestExtractor {
errorObj.body = err.error errorObj.body = err.error
} }
return observableThrowError(errorObj) return observableThrowError(() => errorObj)
} }
redirectTo404IfNotFound (obj: { status: number }, type: 'video' | 'other', status = [ HttpStatusCode.NOT_FOUND_404 ]) { redirectTo404IfNotFound (obj: { status: number }, type: 'video' | 'other', status = [ HttpStatusCode.NOT_FOUND_404 ]) {
@ -98,6 +98,6 @@ export class RestExtractor {
this.router.navigate([ '/404' ], { state: { type, obj }, skipLocationChange: true }) this.router.navigate([ '/404' ], { state: { type, obj }, skipLocationChange: true })
} }
return observableThrowError(obj) return observableThrowError(() => obj)
} }
} }

View File

@ -36,14 +36,14 @@ export class NotificationComponent implements OnInit, OnDestroy {
ngOnInit () { ngOnInit () {
this.userNotificationService.countUnreadNotifications() this.userNotificationService.countUnreadNotifications()
.subscribe( .subscribe({
result => { next: result => {
this.unreadNotifications = Math.min(result, 99) // Limit number to 99 this.unreadNotifications = Math.min(result, 99) // Limit number to 99
this.subscribeToNotifications() this.subscribeToNotifications()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
this.routeSub = this.router.events this.routeSub = this.router.events
.pipe(filter(event => event instanceof NavigationEnd)) .pipe(filter(event => event instanceof NavigationEnd))

View File

@ -50,10 +50,10 @@ export class InstanceConfigWarningModalComponent {
peertubeLocalStorage.setItem(this.LOCAL_STORAGE_KEYS.NO_INSTANCE_CONFIG_WARNING_MODAL, 'true') peertubeLocalStorage.setItem(this.LOCAL_STORAGE_KEYS.NO_INSTANCE_CONFIG_WARNING_MODAL, 'true')
this.userService.updateMyProfile({ noInstanceConfigWarningModal: true }) this.userService.updateMyProfile({ noInstanceConfigWarningModal: true })
.subscribe( .subscribe({
() => console.log('We will not open the instance config warning modal again.'), next: () => console.log('We will not open the instance config warning modal again.'),
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -31,20 +31,20 @@ export class QuickSettingsModalComponent extends FormReactive implements OnInit
ngOnInit () { ngOnInit () {
this.user = this.userService.getAnonymousUser() this.user = this.userService.getAnonymousUser()
this.localStorageService.watch() this.localStorageService.watch()
.subscribe( .subscribe({
() => this.user = this.userService.getAnonymousUser() next: () => this.user = this.userService.getAnonymousUser()
) })
this.userInformationLoaded.next(true) this.userInformationLoaded.next(true)
this.authService.loginChangedSource this.authService.loginChangedSource
.pipe(filter(status => status !== AuthStatus.LoggedIn)) .pipe(filter(status => status !== AuthStatus.LoggedIn))
.subscribe( .subscribe({
() => { next: () => {
this.user = this.userService.getAnonymousUser() this.user = this.userService.getAnonymousUser()
this.userInformationLoaded.next(true) this.userInformationLoaded.next(true)
} }
) })
} }
isUserLoggedIn () { isUserLoggedIn () {

View File

@ -37,10 +37,10 @@ export class WelcomeModalComponent {
peertubeLocalStorage.setItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL, 'true') peertubeLocalStorage.setItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL, 'true')
this.userService.updateMyProfile({ noWelcomeModal: true }) this.userService.updateMyProfile({ noWelcomeModal: true })
.subscribe( .subscribe({
() => console.log('We will not open the welcome modal again.'), next: () => console.log('We will not open the welcome modal again.'),
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -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`) const res = await this.confirmService.confirm($localize`Do you really want to delete this abuse report?`, $localize`Delete`)
if (res === false) return if (res === false) return
this.abuseService.removeAbuse(abuse).subscribe( this.abuseService.removeAbuse(abuse)
() => { .subscribe({
next: () => {
this.notifier.success($localize`Abuse deleted.`) this.notifier.success($localize`Abuse deleted.`)
this.reloadData() this.reloadData()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
updateAbuseState (abuse: AdminAbuse, state: AbuseState) { updateAbuseState (abuse: AdminAbuse, state: AbuseState) {
this.abuseService.updateAbuse(abuse, { state }) this.abuseService.updateAbuse(abuse, { state })
.subscribe( .subscribe({
() => this.reloadData(), next: () => this.reloadData(),
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
onCountMessagesUpdated (event: { abuseId: number, countMessages: number }) { onCountMessagesUpdated (event: { abuseId: number, countMessages: number }) {
@ -198,8 +199,8 @@ export class AbuseListTableComponent extends RestTable implements OnInit {
? this.abuseService.getAdminAbuses(options) ? this.abuseService.getAdminAbuses(options)
: this.abuseService.getUserAbuses(options) : this.abuseService.getUserAbuses(options)
return observable.subscribe( return observable.subscribe({
async resultList => { next: async resultList => {
this.totalRecords = resultList.total this.totalRecords = resultList.total
this.abuses = [] this.abuses = []
@ -245,8 +246,8 @@ export class AbuseListTableComponent extends RestTable implements OnInit {
} }
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
private buildInternalActions (): DropdownAction<ProcessedAbuse>[] { private buildInternalActions (): DropdownAction<ProcessedAbuse>[] {
@ -351,15 +352,15 @@ export class AbuseListTableComponent extends RestTable implements OnInit {
isDisplayed: abuse => abuse.video && !abuse.video.deleted && !abuse.video.blacklisted, isDisplayed: abuse => abuse.video && !abuse.video.deleted && !abuse.video.blacklisted,
handler: abuse => { handler: abuse => {
this.videoBlocklistService.blockVideo(abuse.video.id, undefined, abuse.video.channel.isLocal) this.videoBlocklistService.blockVideo(abuse.video.id, undefined, abuse.video.channel.isLocal)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Video blocked.`) this.notifier.success($localize`Video blocked.`)
this.updateAbuseState(abuse, AbuseState.ACCEPTED) 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, isDisplayed: abuse => abuse.video && !abuse.video.deleted && abuse.video.blacklisted,
handler: abuse => { handler: abuse => {
this.videoBlocklistService.unblockVideo(abuse.video.id) this.videoBlocklistService.unblockVideo(abuse.video.id)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Video unblocked.`) this.notifier.success($localize`Video unblocked.`)
this.updateAbuseState(abuse, AbuseState.ACCEPTED) 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 if (res === false) return
this.videoService.removeVideo(abuse.video.id) this.videoService.removeVideo(abuse.video.id)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Video deleted.`) this.notifier.success($localize`Video deleted.`)
this.updateAbuseState(abuse, AbuseState.ACCEPTED) 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 if (res === false) return
this.commentService.deleteVideoComment(abuse.comment.video.id, abuse.comment.id) this.commentService.deleteVideoComment(abuse.comment.video.id, abuse.comment.id)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Comment deleted.`) this.notifier.success($localize`Comment deleted.`)
this.updateAbuseState(abuse, AbuseState.ACCEPTED) 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) { private muteAccountHelper (account: Account) {
this.blocklistService.blockAccountByInstance(account) this.blocklistService.blockAccountByInstance(account)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Account ${account.nameWithHost} muted by the instance.`) this.notifier.success($localize`Account ${account.nameWithHost} muted by the instance.`)
account.mutedByInstance = true account.mutedByInstance = true
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
private muteServerHelper (host: string) { private muteServerHelper (host: string) {
this.blocklistService.blockServerByInstance(host) this.blocklistService.blockServerByInstance(host)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Server ${host} muted by the instance.`) 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) { private toHtml (text: string) {

View File

@ -61,8 +61,8 @@ export class AbuseMessageModalComponent extends FormReactive implements OnInit {
this.sendingMessage = true this.sendingMessage = true
this.abuseService.addAbuseMessage(this.abuse, this.form.value['message']) this.abuseService.addAbuseMessage(this.abuse, this.form.value['message'])
.subscribe( .subscribe({
() => { next: () => {
this.form.reset() this.form.reset()
this.sendingMessage = false this.sendingMessage = false
this.countMessagesUpdated.emit({ abuseId: this.abuse.id, countMessages: this.abuseMessages.length + 1 }) 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() this.loadMessages()
}, },
err => { error: err => {
this.sendingMessage = false this.sendingMessage = false
console.error(err) console.error(err)
this.notifier.error('Sorry but you cannot send this message. Please retry later') this.notifier.error('Sorry but you cannot send this message. Please retry later')
} }
) })
} }
deleteMessage (abuseMessage: AbuseMessage) { deleteMessage (abuseMessage: AbuseMessage) {
this.abuseService.deleteAbuseMessage(this.abuse, abuseMessage) this.abuseService.deleteAbuseMessage(this.abuse, abuseMessage)
.subscribe( .subscribe({
() => { next: () => {
this.countMessagesUpdated.emit({ abuseId: this.abuse.id, countMessages: this.abuseMessages.length - 1 }) this.countMessagesUpdated.emit({ abuseId: this.abuse.id, countMessages: this.abuseMessages.length - 1 })
this.abuseMessages = this.abuseMessages.filter(m => m.id !== abuseMessage.id) 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) { isMessageByMe (abuseMessage: AbuseMessage) {
@ -105,8 +105,8 @@ export class AbuseMessageModalComponent extends FormReactive implements OnInit {
private loadMessages () { private loadMessages () {
this.abuseService.listAbuseMessages(this.abuse) this.abuseService.listAbuseMessages(this.abuse)
.subscribe( .subscribe({
async res => { next: async res => {
this.abuseMessages = [] this.abuseMessages = []
for (const m of res.data) { 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)
) })
} }
} }

View File

@ -53,16 +53,16 @@ export class ModerationCommentModalComponent extends FormReactive implements OnI
const moderationComment: string = this.form.value[ 'moderationComment' ] const moderationComment: string = this.form.value[ 'moderationComment' ]
this.abuseService.updateAbuse(this.abuseToComment, { moderationComment }) this.abuseService.updateAbuse(this.abuseToComment, { moderationComment })
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Comment updated.`) this.notifier.success($localize`Comment updated.`)
this.commentUpdated.emit(moderationComment) this.commentUpdated.emit(moderationComment)
this.hide() this.hide()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -1,4 +1,4 @@
import { first } from 'rxjs/operators' import { firstValueFrom } from 'rxjs'
import { ComponentRef, Injectable } from '@angular/core' import { ComponentRef, Injectable } from '@angular/core'
import { MarkdownService } from '@app/core' import { MarkdownService } from '@app/core'
import { import {
@ -85,7 +85,7 @@ export class CustomMarkupService {
const component = this.execAngularBuilder(selector, e) const component = this.execAngularBuilder(selector, e)
if (component.instance.loaded) { if (component.instance.loaded) {
const p = component.instance.loaded.pipe(first()).toPromise() const p = firstValueFrom(component.instance.loaded)
loadedPromises.push(p) loadedPromises.push(p)
} }

View File

@ -44,14 +44,14 @@ export class ChannelMiniatureMarkupComponent implements CustomMarkupComponent, O
tap(html => this.descriptionHTML = html), tap(html => this.descriptionHTML = html),
switchMap(() => this.loadVideosObservable()), switchMap(() => this.loadVideosObservable()),
finalize(() => this.loaded.emit(true)) finalize(() => this.loaded.emit(true))
).subscribe( ).subscribe({
({ total, data }) => { next: ({ total, data }) => {
this.totalVideos = total this.totalVideos = total
this.video = data[0] 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 () { getVideoChannelLink () {

View File

@ -41,10 +41,10 @@ export class PlaylistMiniatureMarkupComponent implements CustomMarkupComponent,
ngOnInit () { ngOnInit () {
this.findInBulkService.getPlaylist(this.uuid) this.findInBulkService.getPlaylist(this.uuid)
.pipe(finalize(() => this.loaded.emit(true))) .pipe(finalize(() => this.loaded.emit(true)))
.subscribe( .subscribe({
playlist => this.playlist = playlist, 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}`)
) })
} }
} }

View File

@ -53,10 +53,10 @@ export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnI
this.findInBulk.getVideo(this.uuid) this.findInBulk.getVideo(this.uuid)
.pipe(finalize(() => this.loaded.emit(true))) .pipe(finalize(() => this.loaded.emit(true)))
.subscribe( .subscribe({
video => this.video = video, 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}`)
) })
} }
} }

View File

@ -71,11 +71,11 @@ export class VideosListMarkupComponent implements CustomMarkupComponent, OnInit
return this.getVideosObservable() return this.getVideosObservable()
.pipe(finalize(() => this.loaded.emit(true))) .pipe(finalize(() => this.loaded.emit(true)))
.subscribe( .subscribe({
({ data }) => this.videos = data, 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 () { getVideosObservable () {

View File

@ -36,8 +36,8 @@ export class InstanceAboutAccordionComponent implements OnInit {
ngOnInit (): void { ngOnInit (): void {
this.instanceService.getAbout() this.instanceService.getAbout()
.subscribe( .subscribe({
async about => { next: async about => {
this.about = about this.about = about
this.aboutHtml = await this.instanceService.buildHtml(about) this.aboutHtml = await this.instanceService.buildHtml(about)
@ -45,8 +45,8 @@ export class InstanceAboutAccordionComponent implements OnInit {
this.init.emit(this) this.init.emit(this)
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
getAdministratorsPanel () { getAdministratorsPanel () {

View File

@ -36,7 +36,7 @@ export class AuthInterceptor implements HttpInterceptor {
return this.handleNotAuthenticated(err) return this.handleNotAuthenticated(err)
} }
return observableThrowError(err) return observableThrowError(() => err)
}) })
) )
} }

View File

@ -56,8 +56,8 @@ export class UserNotificationsComponent implements OnInit {
} }
this.userNotificationService.listMyNotifications(options) this.userNotificationService.listMyNotifications(options)
.subscribe( .subscribe({
result => { next: result => {
this.notifications = reset ? result.data : this.notifications.concat(result.data) this.notifications = reset ? result.data : this.notifications.concat(result.data)
this.componentPagination.totalItems = result.total this.componentPagination.totalItems = result.total
@ -66,8 +66,8 @@ export class UserNotificationsComponent implements OnInit {
this.onDataSubject.next(result.data) this.onDataSubject.next(result.data)
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
onNearOfBottom () { onNearOfBottom () {
@ -84,26 +84,26 @@ export class UserNotificationsComponent implements OnInit {
if (notification.read) return if (notification.read) return
this.userNotificationService.markAsRead(notification) this.userNotificationService.markAsRead(notification)
.subscribe( .subscribe({
() => { next: () => {
notification.read = true notification.read = true
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
markAllAsRead () { markAllAsRead () {
this.userNotificationService.markAllAsRead() this.userNotificationService.markAllAsRead()
.subscribe( .subscribe({
() => { next: () => {
for (const notification of this.notifications) { for (const notification of this.notifications) {
notification.read = true notification.read = true
} }
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
changeSortColumn (column: string) { changeSortColumn (column: string) {

View File

@ -62,13 +62,13 @@ export class GenericAccountBlocklistComponent extends RestTable implements OnIni
search: this.search search: this.search
}) })
return operation.subscribe( return operation.subscribe({
resultList => { next: resultList => {
this.blockedAccounts = resultList.data this.blockedAccounts = resultList.data
this.totalRecords = resultList.total this.totalRecords = resultList.total
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -77,14 +77,14 @@ export class AccountReportComponent extends FormReactive implements OnInit {
account: { account: {
id: this.account.id id: this.account.id
} }
}).subscribe( }).subscribe({
() => { next: () => {
this.notifier.success($localize`Account reported.`) this.notifier.success($localize`Account reported.`)
this.hide() this.hide()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
isRemote () { isRemote () {

View File

@ -77,14 +77,14 @@ export class CommentReportComponent extends FormReactive implements OnInit {
comment: { comment: {
id: this.comment.id id: this.comment.id
} }
}).subscribe( }).subscribe({
() => { next: () => {
this.notifier.success($localize`Comment reported.`) this.notifier.success($localize`Comment reported.`)
this.hide() this.hide()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
isRemote () { isRemote () {

View File

@ -108,14 +108,14 @@ export class VideoReportComponent extends FormReactive implements OnInit {
startAt: hasStart && startAt ? startAt : undefined, startAt: hasStart && startAt ? startAt : undefined,
endAt: hasEnd && endAt ? endAt : undefined endAt: hasEnd && endAt ? endAt : undefined
} }
}).subscribe( }).subscribe({
() => { next: () => {
this.notifier.success($localize`Video reported.`) this.notifier.success($localize`Video reported.`)
this.hide() this.hide()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
isRemote () { isRemote () {

View File

@ -88,13 +88,13 @@ export class GenericServerBlocklistComponent extends RestTable implements OnInit
search: this.search search: this.search
}) })
return operation.subscribe( return operation.subscribe({
resultList => { next: resultList => {
this.blockedServers = resultList.data this.blockedServers = resultList.data
this.totalRecords = resultList.total this.totalRecords = resultList.total
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -47,8 +47,8 @@ export class UserBanModalComponent extends FormReactive implements OnInit {
const reason = this.form.value['reason'] || undefined const reason = this.form.value['reason'] || undefined
this.userService.banUsers(this.usersToBan, reason) this.userService.banUsers(this.usersToBan, reason)
.subscribe( .subscribe({
() => { next: () => {
const message = Array.isArray(this.usersToBan) const message = Array.isArray(this.usersToBan)
? $localize`${this.usersToBan.length} users banned.` ? $localize`${this.usersToBan.length} users banned.`
: $localize`User ${this.usersToBan.username} banned.` : $localize`User ${this.usersToBan.username} banned.`
@ -59,8 +59,8 @@ export class UserBanModalComponent extends FormReactive implements OnInit {
this.hide() this.hide()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -67,14 +67,14 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
if (res === false) return if (res === false) return
this.userService.unbanUsers(user) this.userService.unbanUsers(user)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`User ${user.username} unbanned.`) this.notifier.success($localize`User ${user.username} unbanned.`)
this.userChanged.emit() this.userChanged.emit()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
async removeUser (user: User) { async removeUser (user: User) {
@ -87,137 +87,139 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
const res = await this.confirmService.confirm(message, $localize`Delete`) const res = await this.confirmService.confirm(message, $localize`Delete`)
if (res === false) return if (res === false) return
this.userService.removeUser(user).subscribe( this.userService.removeUser(user)
() => { .subscribe({
next: () => {
this.notifier.success($localize`User ${user.username} deleted.`) this.notifier.success($localize`User ${user.username} deleted.`)
this.userDeleted.emit() this.userDeleted.emit()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
setEmailAsVerified (user: User) { setEmailAsVerified (user: User) {
this.userService.updateUser(user.id, { emailVerified: true }).subscribe( this.userService.updateUser(user.id, { emailVerified: true })
() => { .subscribe({
next: () => {
this.notifier.success($localize`User ${user.username} email set as verified`) this.notifier.success($localize`User ${user.username} email set as verified`)
this.userChanged.emit() this.userChanged.emit()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
blockAccountByUser (account: Account) { blockAccountByUser (account: Account) {
this.blocklistService.blockAccountByUser(account) this.blocklistService.blockAccountByUser(account)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Account ${account.nameWithHost} muted.`) this.notifier.success($localize`Account ${account.nameWithHost} muted.`)
this.account.mutedByUser = true this.account.mutedByUser = true
this.userChanged.emit() this.userChanged.emit()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
unblockAccountByUser (account: Account) { unblockAccountByUser (account: Account) {
this.blocklistService.unblockAccountByUser(account) this.blocklistService.unblockAccountByUser(account)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Account ${account.nameWithHost} unmuted.`) this.notifier.success($localize`Account ${account.nameWithHost} unmuted.`)
this.account.mutedByUser = false this.account.mutedByUser = false
this.userChanged.emit() this.userChanged.emit()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
blockServerByUser (host: string) { blockServerByUser (host: string) {
this.blocklistService.blockServerByUser(host) this.blocklistService.blockServerByUser(host)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Instance ${host} muted.`) this.notifier.success($localize`Instance ${host} muted.`)
this.account.mutedServerByUser = true this.account.mutedServerByUser = true
this.userChanged.emit() this.userChanged.emit()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
unblockServerByUser (host: string) { unblockServerByUser (host: string) {
this.blocklistService.unblockServerByUser(host) this.blocklistService.unblockServerByUser(host)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Instance ${host} unmuted.`) this.notifier.success($localize`Instance ${host} unmuted.`)
this.account.mutedServerByUser = false this.account.mutedServerByUser = false
this.userChanged.emit() this.userChanged.emit()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
blockAccountByInstance (account: Account) { blockAccountByInstance (account: Account) {
this.blocklistService.blockAccountByInstance(account) this.blocklistService.blockAccountByInstance(account)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Account ${account.nameWithHost} muted by the instance.`) this.notifier.success($localize`Account ${account.nameWithHost} muted by the instance.`)
this.account.mutedByInstance = true this.account.mutedByInstance = true
this.userChanged.emit() this.userChanged.emit()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
unblockAccountByInstance (account: Account) { unblockAccountByInstance (account: Account) {
this.blocklistService.unblockAccountByInstance(account) this.blocklistService.unblockAccountByInstance(account)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Account ${account.nameWithHost} unmuted by the instance.`) this.notifier.success($localize`Account ${account.nameWithHost} unmuted by the instance.`)
this.account.mutedByInstance = false this.account.mutedByInstance = false
this.userChanged.emit() this.userChanged.emit()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
blockServerByInstance (host: string) { blockServerByInstance (host: string) {
this.blocklistService.blockServerByInstance(host) this.blocklistService.blockServerByInstance(host)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Instance ${host} muted by the instance.`) this.notifier.success($localize`Instance ${host} muted by the instance.`)
this.account.mutedServerByInstance = true this.account.mutedServerByInstance = true
this.userChanged.emit() this.userChanged.emit()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
unblockServerByInstance (host: string) { unblockServerByInstance (host: string) {
this.blocklistService.unblockServerByInstance(host) this.blocklistService.unblockServerByInstance(host)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Instance ${host} unmuted by the instance.`) this.notifier.success($localize`Instance ${host} unmuted by the instance.`)
this.account.mutedServerByInstance = false this.account.mutedServerByInstance = false
this.userChanged.emit() this.userChanged.emit()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
async bulkRemoveCommentsOf (body: BulkRemoveCommentsOfBody) { async bulkRemoveCommentsOf (body: BulkRemoveCommentsOfBody) {
@ -226,13 +228,13 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
if (res === false) return if (res === false) return
this.bulkService.removeCommentsOf(body) this.bulkService.removeCommentsOf(body)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Will remove comments of this account (may take several minutes).`) 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) { getRouterUserEditLink (user: User) {

View File

@ -55,8 +55,8 @@ export class VideoBlockComponent extends FormReactive implements OnInit {
const unfederate = this.video.isLocal ? this.form.value[ 'unfederate' ] : undefined const unfederate = this.video.isLocal ? this.form.value[ 'unfederate' ] : undefined
this.videoBlocklistService.blockVideo(this.video.id, reason, unfederate) this.videoBlocklistService.blockVideo(this.video.id, reason, unfederate)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Video blocked.`) this.notifier.success($localize`Video blocked.`)
this.hide() this.hide()
@ -66,7 +66,7 @@ export class VideoBlockComponent extends FormReactive implements OnInit {
this.videoBlocked.emit() this.videoBlocked.emit()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }

View File

@ -1,5 +1,5 @@
import * as debug from 'debug' import * as debug from 'debug'
import { Observable, Subject, throwError } from 'rxjs' import { Observable, Subject } from 'rxjs'
import { first, map } from 'rxjs/operators' import { first, map } from 'rxjs/operators'
import { Injectable, NgZone } from '@angular/core' import { Injectable, NgZone } from '@angular/core'
import { buildBulkObservable } from '@app/helpers' import { buildBulkObservable } from '@app/helpers'

View File

@ -65,18 +65,21 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn
} }
if (this.authService.isLoggedIn()) { if (this.authService.isLoggedIn()) {
this.userService.updateMyProfile(details).subscribe( this.userService.updateMyProfile(details)
() => { .subscribe({
next: () => {
this.authService.refreshUserInformation() this.authService.refreshUserInformation()
if (this.notifyOnUpdate) this.notifier.success($localize`Interface settings updated.`) if (this.notifyOnUpdate) this.notifier.success($localize`Interface settings updated.`)
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} else {
return
}
this.userService.updateMyAnonymousProfile(details) this.userService.updateMyAnonymousProfile(details)
if (this.notifyOnUpdate) this.notifier.success($localize`Interface settings updated.`) if (this.notifyOnUpdate) this.notifier.success($localize`Interface settings updated.`)
} }
}
} }

View File

@ -162,15 +162,16 @@ export class UserVideoSettingsComponent extends FormReactive implements OnInit,
} }
private updateLoggedProfile (details: UserUpdateMe) { private updateLoggedProfile (details: UserUpdateMe) {
this.userService.updateMyProfile(details).subscribe( this.userService.updateMyProfile(details)
() => { .subscribe({
next: () => {
this.authService.refreshUserInformation() 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) { private updateAnonymousProfile (details: UserUpdateMe) {

View File

@ -102,8 +102,8 @@ export class SubscribeButtonComponent implements OnInit, OnChanges {
.map(handle => this.userSubscriptionService.addSubscription(handle)) .map(handle => this.userSubscriptionService.addSubscription(handle))
forkJoin(observableBatch) forkJoin(observableBatch)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success( this.notifier.success(
this.account this.account
? $localize`Subscribed to all current channels of ${this.account.displayName}. You will be notified of all their new videos.` ? $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 () { unsubscribe () {
@ -182,11 +182,11 @@ export class SubscribeButtonComponent implements OnInit, OnChanges {
merge( merge(
this.userSubscriptionService.listenToSubscriptionCacheChange(handle), this.userSubscriptionService.listenToSubscriptionCacheChange(handle),
this.userSubscriptionService.doesSubscriptionExist(handle) this.userSubscriptionService.doesSubscriptionExist(handle)
).subscribe( ).subscribe({
res => this.subscribed.set(handle, res), next: res => this.subscribed.set(handle, res),
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
} }
} }

View File

@ -204,8 +204,9 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte
} }
loadMoreVideos (reset = false) { loadMoreVideos (reset = false) {
this.getVideosObservable(this.pagination.currentPage).subscribe( this.getVideosObservable(this.pagination.currentPage)
({ data }) => { .subscribe({
next: ({ data }) => {
this.hasDoneFirstQuery = true this.hasDoneFirstQuery = true
this.lastQueryLength = data.length this.lastQueryLength = data.length
@ -219,13 +220,13 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte
this.onDataSubject.next(data) this.onDataSubject.next(data)
}, },
error => { error: err => {
const message = $localize`Cannot load more videos. Try again later.` const message = $localize`Cannot load more videos. Try again later.`
console.error(message, { error }) console.error(message, { err })
this.notifier.error(message) this.notifier.error(message)
} }
) })
} }
reloadVideos () { reloadVideos () {

View File

@ -183,8 +183,8 @@ export class VideoActionsDropdownComponent implements OnChanges {
if (res === false) return if (res === false) return
this.videoBlocklistService.unblockVideo(this.video.id) this.videoBlocklistService.unblockVideo(this.video.id)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Video ${this.video.name} unblocked.`) this.notifier.success($localize`Video ${this.video.name} unblocked.`)
this.video.blacklisted = false this.video.blacklisted = false
@ -193,8 +193,8 @@ export class VideoActionsDropdownComponent implements OnChanges {
this.videoUnblocked.emit() this.videoUnblocked.emit()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
async removeVideo () { async removeVideo () {
@ -209,40 +209,40 @@ export class VideoActionsDropdownComponent implements OnChanges {
if (res === false) return if (res === false) return
this.videoService.removeVideo(this.video.id) this.videoService.removeVideo(this.video.id)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Video ${this.video.name} deleted.`) this.notifier.success($localize`Video ${this.video.name} deleted.`)
this.videoRemoved.emit() this.videoRemoved.emit()
}, },
error => this.notifier.error(error.message) error: err => this.notifier.error(err.message)
) })
} }
duplicateVideo () { duplicateVideo () {
this.redundancyService.addVideoRedundancy(this.video) this.redundancyService.addVideoRedundancy(this.video)
.subscribe( .subscribe({
() => { next: () => {
const message = $localize`This video will be duplicated by your instance.` const message = $localize`This video will be duplicated by your instance.`
this.notifier.success(message) this.notifier.success(message)
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
muteVideoAccount () { muteVideoAccount () {
const params = { nameWithHost: Actor.CREATE_BY_STRING(this.video.account.name, this.video.account.host) } const params = { nameWithHost: Actor.CREATE_BY_STRING(this.video.account.name, this.video.account.host) }
this.blocklistService.blockAccountByUser(params) this.blocklistService.blockAccountByUser(params)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Account ${params.nameWithHost} muted.`) this.notifier.success($localize`Account ${params.nameWithHost} muted.`)
this.videoAccountMuted.emit() this.videoAccountMuted.emit()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
onVideoBlocked () { onVideoBlocked () {

View File

@ -1,4 +1,5 @@
import { mapValues, pick } from 'lodash-es' import { mapValues, pick } from 'lodash-es'
import { firstValueFrom } from 'rxjs'
import { tap } from 'rxjs/operators' import { tap } from 'rxjs/operators'
import { Component, ElementRef, Inject, LOCALE_ID, ViewChild } from '@angular/core' import { Component, ElementRef, Inject, LOCALE_ID, ViewChild } from '@angular/core'
import { AuthService, HooksService, Notifier } from '@app/core' import { AuthService, HooksService, Notifier } from '@app/core'
@ -265,6 +266,6 @@ export class VideoDownloadComponent {
const observable = this.videoService.getVideoFileMetadata(file.metadataUrl) const observable = this.videoService.getVideoFileMetadata(file.metadataUrl)
.pipe(tap(res => file.metadata = res)) .pipe(tap(res => file.metadata = res))
return observable.toPromise() return firstValueFrom(observable)
} }
} }

View File

@ -214,7 +214,8 @@ export class VideoMiniatureComponent implements OnInit {
addToWatchLater () { addToWatchLater () {
const body = { videoId: this.video.id } const body = { videoId: this.video.id }
this.videoPlaylistService.addVideoInPlaylist(this.watchLaterPlaylist.id, body).subscribe( this.videoPlaylistService.addVideoInPlaylist(this.watchLaterPlaylist.id, body)
.subscribe(
res => { res => {
this.watchLaterPlaylist.playlistElementId = res.videoPlaylistElement.id this.watchLaterPlaylist.playlistElementId = res.videoPlaylistElement.id
} }

View File

@ -198,15 +198,16 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit,
privacy: VideoPlaylistPrivacy.PRIVATE privacy: VideoPlaylistPrivacy.PRIVATE
} }
this.videoPlaylistService.createVideoPlaylist(videoPlaylistCreate).subscribe( this.videoPlaylistService.createVideoPlaylist(videoPlaylistCreate)
() => { .subscribe({
next: () => {
this.isNewPlaylistBlockOpened = false this.isNewPlaylistBlockOpened = false
this.cd.markForCheck() this.cd.markForCheck()
}, },
err => this.notifier.error(err.message) error: err => this.notifier.error(err.message)
) })
} }
onVideoPlaylistSearchChanged () { onVideoPlaylistSearchChanged () {
@ -268,17 +269,15 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit,
} }
this.videoPlaylistService.updateVideoOfPlaylist(playlist.id, element.playlistElementId, body, this.video.id) this.videoPlaylistService.updateVideoOfPlaylist(playlist.id, element.playlistElementId, body, this.video.id)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Timestamps updated`) this.notifier.success($localize`Timestamps updated`)
}, },
err => { error: err => this.notifier.error(err.message),
this.notifier.error(err.message)
},
() => this.cd.markForCheck() complete: () => this.cd.markForCheck()
) })
} }
private isOptionalRowDisplayed (playlist: PlaylistSummary) { private isOptionalRowDisplayed (playlist: PlaylistSummary) {
@ -302,17 +301,15 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit,
private removeVideoFromPlaylist (playlist: PlaylistSummary, elementId: number) { private removeVideoFromPlaylist (playlist: PlaylistSummary, elementId: number) {
this.videoPlaylistService.removeVideoFromPlaylist(playlist.id, elementId, this.video.id) this.videoPlaylistService.removeVideoFromPlaylist(playlist.id, elementId, this.video.id)
.subscribe( .subscribe({
() => { next: () => {
this.notifier.success($localize`Video removed from ${playlist.displayName}`) this.notifier.success($localize`Video removed from ${playlist.displayName}`)
}, },
err => { error: err => this.notifier.error(err.message),
this.notifier.error(err.message)
},
() => this.cd.markForCheck() complete: () => this.cd.markForCheck()
) })
} }
private listenToVideoPlaylistChange () { 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 if (element.stopTimestamp && element.stopTimestamp !== this.video.duration) body.stopTimestamp = element.stopTimestamp
this.videoPlaylistService.addVideoInPlaylist(playlist.id, body) this.videoPlaylistService.addVideoInPlaylist(playlist.id, body)
.subscribe( .subscribe({
res => { next: res => {
const message = body.startTimestamp || body.stopTimestamp const message = body.startTimestamp || body.stopTimestamp
? $localize`Video added in ${playlist.displayName} at timestamps ${this.formatTimestamp(element)}` ? $localize`Video added in ${playlist.displayName} at timestamps ${this.formatTimestamp(element)}`
: $localize`Video added in ${playlist.displayName}` : $localize`Video added in ${playlist.displayName}`
@ -382,12 +379,10 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit,
if (element) element.playlistElementId = res.videoPlaylistElement.id if (element) element.playlistElementId = res.videoPlaylistElement.id
}, },
err => { error: err => this.notifier.error(err.message),
this.notifier.error(err.message)
},
() => this.cd.markForCheck() complete: () => this.cd.markForCheck()
) })
} }
private formatTimestamp (element: PlaylistElement) { private formatTimestamp (element: PlaylistElement) {

Some files were not shown because too many files have changed in this diff Show More