const pagination = this.restService.componentPaginationToRestPagination(this.followersPagination)
this.followService.getFollowers({ pagination: pagination, sort: this.sort, state: 'accepted' })
- .subscribe(
- resultList => {
+ .subscribe({
+ next: resultList => {
if (reset) this.followers = []
const newFollowers = resultList.data.map(r => r.follower.host)
this.followersPagination.totalItems = resultList.total
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
private loadMoreFollowings (reset = false) {
const pagination = this.restService.componentPaginationToRestPagination(this.followingsPagination)
this.followService.getFollowing({ pagination, sort: this.sort, state: 'accepted' })
- .subscribe(
- resultList => {
+ .subscribe({
+ next: resultList => {
if (reset) this.followings = []
const newFollowings = resultList.data.map(r => r.following.host)
this.followingsPagination.totalItems = resultList.total
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
const body = this.form.value[ 'body' ]
this.instanceService.contactAdministrator(fromEmail, fromName, subject, body)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Your message has been sent.`)
this.hide()
},
- err => {
+ error: err => {
this.error = err.status === HttpStatusCode.FORBIDDEN_403
? $localize`You already sent this form recently`
: err.message
}
- )
+ })
}
private prefillForm (prefill: Prefill) {
HttpStatusCode.NOT_FOUND_404
]))
)
- .subscribe(
- videoChannels => this.videoChannels = videoChannels.data,
+ .subscribe({
+ next: videoChannels => this.videoChannels = videoChannels.data,
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
this.links = [
{ label: $localize`CHANNELS`, routerLink: 'video-channels' },
const user = this.authService.getUser()
if (user.hasRight(UserRight.MANAGE_USERS)) {
- this.userService.getUser(account.userId).subscribe(
- accountUser => this.accountUser = accountUser,
+ this.userService.getUser(account.userId)
+ .subscribe({
+ next: accountUser => this.accountUser = accountUser,
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
this.configService.updateCustomConfig(omit(value, 'instanceCustomHomepage')),
this.customPage.updateInstanceHomepage(value.instanceCustomHomepage.content)
])
- .subscribe(
- ([ resConfig ]) => {
+ .subscribe({
+ next: ([ resConfig ]) => {
const instanceCustomHomepage = {
content: value.instanceCustomHomepage.content
}
this.notifier.success($localize`Configuration updated.`)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
hasConsistentOptions () {
forkJoin([
this.configService.getCustomConfig(),
this.customPage.getInstanceHomepage()
- ])
- .subscribe(([ config, homepage ]) => {
+ ]).subscribe({
+ next: ([ config, homepage ]) => {
this.customConfig = { ...config, instanceCustomHomepage: homepage }
this.updateForm()
this.forceCheck()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
private loadCategoriesAndLanguages () {
forkJoin([
this.serverService.getVideoLanguages(),
this.serverService.getVideoCategories()
- ]).subscribe(
- ([ languages, categories ]) => {
+ ]).subscribe({
+ next: ([ languages, categories ]) => {
this.languageItems = languages.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)
+ })
}
}
follow.state = 'accepted'
this.followService.acceptFollower(follow)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
const handle = follow.follower.name + '@' + follow.follower.host
this.notifier.success($localize`${handle} accepted in instance followers`)
},
- err => {
+ error: err => {
follow.state = 'pending'
this.notifier.error(err.message)
}
- )
+ })
}
async rejectFollower (follow: ActorFollow) {
if (res === false) return
this.followService.rejectFollower(follow)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
const handle = follow.follower.name + '@' + follow.follower.host
this.notifier.success($localize`${handle} rejected from instance followers`)
this.reloadData()
},
- err => {
+ error: err => {
follow.state = 'pending'
this.notifier.error(err.message)
}
- )
+ })
}
async deleteFollower (follow: ActorFollow) {
if (res === false) return
this.followService.removeFollower(follow)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
const handle = follow.follower.name + '@' + follow.follower.host
this.notifier.success($localize`${handle} removed from instance followers`)
this.reloadData()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
protected reloadData () {
this.followService.getFollowers({ pagination: this.pagination, sort: this.sort, search: this.search })
- .subscribe(
- resultList => {
+ .subscribe({
+ next: resultList => {
this.followers = resultList.data
this.totalRecords = resultList.total
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
private async addFollowing () {
const hostsOrHandles = splitAndGetNotEmpty(this.form.value['hostsOrHandles'])
- this.followService.follow(hostsOrHandles).subscribe(
- () => {
- this.notifier.success($localize`Follow request(s) sent!`)
- this.newFollow.emit()
- },
+ this.followService.follow(hostsOrHandles)
+ .subscribe({
+ next: () => {
+ this.notifier.success($localize`Follow request(s) sent!`)
+ this.newFollow.emit()
+ },
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
)
if (res === false) return
- this.followService.unfollow(follow).subscribe(
- () => {
- this.notifier.success($localize`You are not following ${follow.following.host} anymore.`)
- this.reloadData()
- },
+ this.followService.unfollow(follow)
+ .subscribe({
+ next: () => {
+ this.notifier.success($localize`You are not following ${follow.following.host} anymore.`)
+ this.reloadData()
+ },
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
protected reloadData () {
this.followService.getFollowing({ pagination: this.pagination, sort: this.sort, search: this.search })
- .subscribe(
- resultList => {
+ .subscribe({
+ next: resultList => {
this.following = resultList.data
this.totalRecords = resultList.total
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
updateRedundancyState () {
this.redundancyService.updateRedundancy(this.host, this.redundancyAllowed)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
const stateLabel = this.redundancyAllowed ? $localize`enabled` : $localize`disabled`
this.notifier.success($localize`Redundancy for ${this.host} is ${stateLabel}`)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
if (res === false) return
this.redundancyService.removeVideoRedundancies(redundancy)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Video redundancies removed!`)
this.reloadData()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
this.redundancyService.listVideoRedundancies(options)
- .subscribe(
- resultList => {
+ .subscribe({
+ next: resultList => {
this.videoRedundancies = resultList.data
this.totalRecords = resultList.total
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
private loadSelectLocalStorage () {
handler: videoBlock => {
this.videoBlocklistService.unblockVideo(videoBlock.video.id).pipe(
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.reloadData()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
},
isDisplayed: videoBlock => videoBlock.type === VideoBlacklistType.AUTO_BEFORE_PUBLISHED
}
if (res === false) return
this.videoService.removeVideo(videoBlock.video.id)
- .subscribe(
- () => {
- this.notifier.success($localize`Video deleted.`)
- },
+ .subscribe({
+ next: () => this.notifier.success($localize`Video deleted.`),
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
]
const res = await this.confirmService.confirm(confirmMessage, $localize`Unblock`)
if (res === false) return
- this.videoBlocklistService.unblockVideo(entry.video.id).subscribe(
- () => {
- this.notifier.success($localize`Video ${entry.video.name} unblocked.`)
- this.reloadData()
- },
+ this.videoBlocklistService.unblockVideo(entry.video.id)
+ .subscribe({
+ next: () => {
+ this.notifier.success($localize`Video ${entry.video.name} unblocked.`)
+ this.reloadData()
+ },
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
getVideoEmbed (entry: VideoBlacklist) {
sort: this.sort,
search: this.search
})
- .subscribe(
- async resultList => {
+ .subscribe({
+ next: async resultList => {
this.totalRecords = resultList.total
this.blocklist = resultList.data
}
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
<ng-template pTemplate="header">
<tr>
- <th style="width: 40px">
+ <th style="width: 40px;">
<p-tableHeaderCheckbox ariaLabel="Select all rows" i18n-ariaLabel></p-tableHeaderCheckbox>
</th>
- <th style="width: 40px"></th>
+ <th style="width: 40px;"></th>
<th style="width: 150px;"></th>
- <th style="width: 300px" i18n>Account</th>
- <th style="width: 300px" i18n>Video</th>
+ <th style="width: 300px;" i18n>Account</th>
+ <th style="width: 300px;" i18n>Video</th>
<th i18n>Comment</th>
<th style="width: 150px;" i18n pSortableColumn="createdAt">Date <p-sortIcon field="createdAt"></p-sortIcon></th>
</tr>
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 { AuthService, ConfirmService, MarkdownService, Notifier, RestPagination, RestTable } from '@app/core'
import { AdvancedInputFilter } from '@app/shared/shared-forms'
pagination: this.pagination,
sort: this.sort,
search: this.search
- }).subscribe(
- async resultList => {
- this.totalRecords = resultList.total
+ }).subscribe({
+ next: async resultList => {
+ this.totalRecords = resultList.total
- this.comments = []
+ this.comments = []
- for (const c of resultList.data) {
- this.comments.push(
- new VideoCommentAdmin(c, await this.toHtml(c.text))
- )
- }
- },
+ for (const c of resultList.data) {
+ this.comments.push(
+ new VideoCommentAdmin(c, await this.toHtml(c.text))
+ )
+ }
+ },
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
private async removeComments (comments: VideoCommentAdmin[]) {
const commentArgs = comments.map(c => ({ videoId: c.video.id, commentId: c.id }))
- this.videoCommentService.deleteVideoComments(commentArgs).subscribe(
- () => {
- this.notifier.success($localize`${commentArgs.length} comments deleted.`)
- this.reloadData()
- },
+ this.videoCommentService.deleteVideoComments(commentArgs)
+ .subscribe({
+ next: () => {
+ this.notifier.success($localize`${commentArgs.length} comments deleted.`)
+ this.reloadData()
+ },
- err => this.notifier.error(err.message),
+ error: err => this.notifier.error(err.message),
- () => this.selectedComments = []
- )
+ complete: () => this.selectedComments = []
+ })
}
private deleteComment (comment: VideoCommentAdmin) {
this.videoCommentService.deleteVideoComment(comment.video.id, comment.id)
- .subscribe(
- () => this.reloadData(),
+ .subscribe({
+ next: () => this.reloadData(),
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
private async deleteUserComments (comment: VideoCommentAdmin) {
}
this.bulkService.removeCommentsOf(options)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
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)
+ })
}
}
loadMorePlugins () {
this.pluginApiService.getPlugins(this.pluginType, this.pagination, this.sort)
- .subscribe(
- res => {
+ .subscribe({
+ next: res => {
this.plugins = this.plugins.concat(res.data)
this.pagination.totalItems = res.total
this.onDataSubject.next(res.data)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
onNearOfBottom () {
if (res === false) return
this.pluginApiService.uninstall(plugin.name, plugin.type)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`${plugin.name} uninstalled.`)
this.plugins = this.plugins.filter(p => p.name !== plugin.name)
this.pagination.totalItems--
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
async update (plugin: PeerTubePlugin) {
this.pluginApiService.update(plugin.name, plugin.type)
.pipe()
- .subscribe(
- res => {
+ .subscribe({
+ next: res => {
this.updating[updatingKey] = false
this.notifier.success($localize`${plugin.name} updated.`)
Object.assign(plugin, res)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
getShowRouterLink (plugin: PeerTubePlugin) {
this.isSearching = true
this.pluginApiService.searchAvailablePlugins(this.pluginType, this.pagination, this.sort, this.search)
- .subscribe(
- res => {
+ .subscribe({
+ next: res => {
this.isSearching = false
this.plugins = this.plugins.concat(res.data)
this.onDataSubject.next(res.data)
},
- err => {
+ error: err => {
console.error(err)
const message = $localize`The plugin index is not available. Please retry later.`
this.notifier.error(message)
}
- )
+ })
}
onNearOfBottom () {
this.installing[plugin.npmName] = true
this.pluginApiService.install(plugin.npmName)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.installing[plugin.npmName] = false
this.pluginInstalled = true
plugin.installed = true
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
const settings = this.form.value
this.pluginAPIService.updatePluginSettings(this.plugin.name, this.plugin.type, settings)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Settings updated.`)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
hasRegisteredSettings () {
return this.pluginAPIService.getPluginRegisteredSettings(plugin.name, plugin.type)
.pipe(map(data => ({ plugin, registeredSettings: data.registeredSettings })))
}))
- .subscribe(
- async ({ plugin, registeredSettings }) => {
+ .subscribe({
+ next: async ({ plugin, registeredSettings }) => {
this.plugin = plugin
this.registeredSettings = await this.translateSettings(registeredSettings)
this.buildSettingsForm()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
private buildSettingsForm () {
load () {
this.debugService.getDebug()
- .subscribe(
- debug => this.debug = debug,
+ .subscribe({
+ next: debug => this.debug = debug,
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
pagination: this.pagination,
sort: this.sort
})
- .subscribe(
- resultList => {
+ .subscribe({
+ next: resultList => {
this.jobs = resultList.data
this.totalRecords = resultList.total
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
private loadJobStateAndType () {
this.loading = true
this.logsService.getLogs({ isAuditLog: this.isAuditLog(), level: this.level, startDate: this.startDate })
- .subscribe(
- logs => {
+ .subscribe({
+ next: logs => {
this.logs = logs
setTimeout(() => {
})
},
- err => this.notifier.error(err.message),
+ error: err => this.notifier.error(err.message),
- () => this.loading = false
- )
+ complete: () => this.loading = false
+ })
}
isAuditLog () {
userCreate.videoQuota = parseInt(this.form.value['videoQuota'], 10)
userCreate.videoQuotaDaily = parseInt(this.form.value['videoQuotaDaily'], 10)
- this.userService.addUser(userCreate).subscribe(
- () => {
- this.notifier.success($localize`User ${userCreate.username} created.`)
- this.router.navigate([ '/admin/users/list' ])
- },
+ this.userService.addUser(userCreate)
+ .subscribe({
+ next: () => {
+ this.notifier.success($localize`User ${userCreate.username} created.`)
+ this.router.navigate([ '/admin/users/list' ])
+ },
- err => this.error = err.message
- )
+ error: err => this.error = err.message
+ })
}
isCreation () {
const userUpdate: UserUpdate = this.form.value
- this.userService.updateUser(this.userId, userUpdate).subscribe(
- () => {
- this.notifier.success($localize`Password changed for user ${this.username}.`)
- },
+ this.userService.updateUser(this.userId, userUpdate)
+ .subscribe({
+ next: () => this.notifier.success($localize`Password changed for user ${this.username}.`),
- err => this.error = err.message
- )
+ error: err => this.error = err.message
+ })
}
togglePasswordVisibility () {
this.paramsSub = this.route.params.subscribe(routeParams => {
const userId = routeParams['id']
- this.userService.getUser(userId, true).subscribe(
- user => this.onUserFetched(user),
+ this.userService.getUser(userId, true)
+ .subscribe({
+ next: user => this.onUserFetched(user),
- err => this.error = err.message
- )
+ error: err => this.error = err.message
+ })
})
}
if (userUpdate.pluginAuth === 'null') userUpdate.pluginAuth = null
- this.userService.updateUser(this.user.id, userUpdate).subscribe(
- () => {
- this.notifier.success($localize`User ${this.user.username} updated.`)
- this.router.navigate([ '/admin/users/list' ])
- },
+ this.userService.updateUser(this.user.id, userUpdate)
+ .subscribe({
+ next: () => {
+ this.notifier.success($localize`User ${this.user.username} updated.`)
+ this.router.navigate([ '/admin/users/list' ])
+ },
- err => this.error = err.message
- )
+ error: err => this.error = err.message
+ })
}
isCreation () {
}
resetPassword () {
- this.userService.askResetPassword(this.user.email).subscribe(
- () => {
- this.notifier.success($localize`An email asking for password reset has been sent to ${this.user.username}.`)
- },
-
- err => this.error = err.message
- )
+ 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}.`)
+ },
+
+ error: err => this.error = err.message
+ })
}
private onUserFetched (userJson: UserType) {
if (res === false) return
this.userService.unbanUsers(users)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`${users.length} users unbanned.`)
this.reloadData()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
async removeUsers (users: User[]) {
const res = await this.confirmService.confirm(message, $localize`Delete`)
if (res === false) return
- this.userService.removeUser(users).subscribe(
- () => {
- this.notifier.success($localize`${users.length} users deleted.`)
- this.reloadData()
- },
+ this.userService.removeUser(users)
+ .subscribe({
+ next: () => {
+ this.notifier.success($localize`${users.length} users deleted.`)
+ this.reloadData()
+ },
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
async setEmailsAsVerified (users: User[]) {
- this.userService.updateUsers(users, { emailVerified: true }).subscribe(
- () => {
- this.notifier.success($localize`${users.length} users email set as verified.`)
- this.reloadData()
- },
+ this.userService.updateUsers(users, { emailVerified: true })
+ .subscribe({
+ next: () => {
+ this.notifier.success($localize`${users.length} users email set as verified.`)
+ this.reloadData()
+ },
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
isInSelectionMode () {
pagination: this.pagination,
sort: this.sort,
search: this.search
- }).subscribe(
- resultList => {
+ }).subscribe({
+ next: resultList => {
this.users = resultList.data
this.totalRecords = resultList.total
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
const { username, password } = this.form.value
this.authService.login(username, password)
- .subscribe(
- () => this.redirectService.redirectToPreviousRoute(),
+ .subscribe({
+ next: () => this.redirectService.redirectToPreviousRoute(),
- err => this.handleError(err)
- )
+ error: err => this.handleError(err)
+ })
}
askResetPassword () {
this.userService.askResetPassword(this.forgotPasswordEmail)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
const message = $localize`An email with the reset password instructions will be sent to ${this.forgotPasswordEmail}.
The link will expire within 1 hour.`
this.hideForgotPasswordModal()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
openForgotPasswordModal () {
this.isAuthenticatedWithExternalAuth = true
this.authService.login(username, null, token)
- .subscribe(
- () => this.redirectService.redirectToPreviousRoute(),
-
- err => {
- this.handleError(err)
- this.isAuthenticatedWithExternalAuth = false
- }
- )
+ .subscribe({
+ next: () => this.redirectService.redirectToPreviousRoute(),
+
+ error: err => {
+ this.handleError(err)
+ this.isAuthenticatedWithExternalAuth = false
+ }
+ })
}
private handleError (err: any) {
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 { FeedFormat } from '@shared/models'
import { ScopedToken } from '@shared/models/users/user-scoped-token'
ngOnInit () {
this.feedUrl = this.baseURL
this.scopedTokensService.getScopedTokens()
- .subscribe(
- tokens => this.regenApplications(tokens),
+ .subscribe({
+ next: tokens => this.regenApplications(tokens),
- err => {
- this.notifier.error(err.message)
- }
- )
+ error: err => this.notifier.error(err.message)
+ })
}
async renewToken () {
)
if (res === false) return
- this.scopedTokensService.renewScopedTokens().subscribe(
- tokens => {
- this.regenApplications(tokens)
- this.notifier.success($localize`Token renewed. Update your client configuration accordingly.`)
- },
-
- err => {
- this.notifier.error(err.message)
- }
- )
+ this.scopedTokensService.renewScopedTokens()
+ .subscribe({
+ next: tokens => {
+ this.regenApplications(tokens)
+ this.notifier.success($localize`Token renewed. Update your client configuration accordingly.`)
+ },
+ error: err => this.notifier.error(err.message)
+ })
}
private regenApplications (tokens: ScopedToken) {
this.serverService.getConfig(),
this.userService.changeEmail(password, email)
]).pipe(tap(() => this.authService.refreshUserInformation()))
- .subscribe(
- ([ config ]) => {
+ .subscribe({
+ next: ([ config ]) => {
this.form.reset()
if (config.signup.requiresEmailVerification) {
}
},
- err => {
+ error: err => {
if (err.status === 401) {
this.error = $localize`You current password is invalid.`
return
this.error = err.message
}
- )
+ })
}
}
const currentPassword = this.form.value[ 'current-password' ]
const newPassword = this.form.value[ 'new-password' ]
- this.userService.changePassword(currentPassword, newPassword).subscribe(
- () => {
- this.notifier.success($localize`Password updated.`)
+ this.userService.changePassword(currentPassword, newPassword)
+ .subscribe({
+ next: () => {
+ this.notifier.success($localize`Password updated.`)
- this.form.reset()
- this.error = null
- },
+ this.form.reset()
+ this.error = null
+ },
- err => {
- if (err.status === 401) {
- this.error = $localize`You current password is invalid.`
- return
- }
+ error: err => {
+ if (err.status === 401) {
+ this.error = $localize`You current password is invalid.`
+ return
+ }
- this.error = err.message
- }
- )
+ this.error = err.message
+ }
+ })
}
}
)
if (res === false) return
- this.userService.deleteMe().subscribe(
- () => {
- this.notifier.success($localize`Your account is deleted.`)
+ this.userService.deleteMe()
+ .subscribe({
+ next: () => {
+ this.notifier.success($localize`Your account is deleted.`)
- this.authService.logout()
- this.redirectService.redirectToHomepage()
- },
+ this.authService.logout()
+ this.redirectService.redirectToHomepage()
+ },
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
private savePreferencesImpl () {
this.userNotificationService.updateNotificationSettings(this.user.notificationSettings)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Preferences saved`, undefined, 2000)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
private loadNotificationSettings () {
this.error = null
- this.userService.updateMyProfile({ displayName, description }).subscribe(
- () => {
+ this.userService.updateMyProfile({ displayName, description })
+ .subscribe({
+ next: () => {
this.user.account.displayName = displayName
this.user.account.description = description
this.notifier.success($localize`Profile updated.`)
},
- err => this.error = err.message
- )
+ error: err => this.error = err.message
+ })
}
}
onAvatarChange (formData: FormData) {
this.userService.changeAvatar(formData)
- .subscribe(
- data => {
+ .subscribe({
+ next: data => {
this.notifier.success($localize`Avatar changed.`)
this.user.updateAccountAvatar(data.avatar)
},
- (err: HttpErrorResponse) => genericUploadErrorHandler({
+ error: (err: HttpErrorResponse) => genericUploadErrorHandler({
err,
name: $localize`avatar`,
notifier: this.notifier
})
- )
+ })
}
onAvatarDelete () {
this.userService.deleteAvatar()
- .subscribe(
- data => {
+ .subscribe({
+ next: data => {
this.notifier.success($localize`Avatar deleted.`)
this.user.updateAccountAvatar()
},
- (err: HttpErrorResponse) => this.notifier.error(err.message)
- )
+ error: (err: HttpErrorResponse) => this.notifier.error(err.message)
+ })
}
}
.pipe(
switchMap(() => this.uploadAvatar()),
switchMap(() => this.uploadBanner())
- ).subscribe(
- () => {
+ ).subscribe({
+ next: () => {
this.authService.refreshUserInformation()
this.notifier.success($localize`Video channel ${videoChannelCreate.displayName} created.`)
this.router.navigate(['/my-library', 'video-channels'])
},
- err => {
+ error: err => {
if (err.status === HttpStatusCode.CONFLICT_409) {
this.error = $localize`This name already exists on this instance.`
return
this.error = err.message
}
- )
+ })
}
onAvatarChange (formData: FormData) {
this.paramsSub = this.route.params.subscribe(routeParams => {
const videoChannelId = routeParams['videoChannelId']
- this.videoChannelService.getVideoChannel(videoChannelId).subscribe(
- videoChannelToUpdate => {
- this.videoChannel = videoChannelToUpdate
-
- this.oldSupportField = videoChannelToUpdate.support
-
- this.form.patchValue({
- 'display-name': videoChannelToUpdate.displayName,
- description: videoChannelToUpdate.description,
- support: videoChannelToUpdate.support
- })
- },
+ this.videoChannelService.getVideoChannel(videoChannelId)
+ .subscribe({
+ next: videoChannelToUpdate => {
+ this.videoChannel = videoChannelToUpdate
+
+ this.oldSupportField = videoChannelToUpdate.support
+
+ this.form.patchValue({
+ 'display-name': videoChannelToUpdate.displayName,
+ description: videoChannelToUpdate.description,
+ support: videoChannelToUpdate.support
+ })
+ },
- err => this.error = err.message
- )
+ error: err => this.error = err.message
+ })
})
}
bulkVideosSupportUpdate: body.bulkVideosSupportUpdate || false
}
- this.videoChannelService.updateVideoChannel(this.videoChannel.name, videoChannelUpdate).subscribe(
- () => {
- this.authService.refreshUserInformation()
+ this.videoChannelService.updateVideoChannel(this.videoChannel.name, videoChannelUpdate)
+ .subscribe({
+ next: () => {
+ this.authService.refreshUserInformation()
- this.notifier.success($localize`Video channel ${videoChannelUpdate.displayName} updated.`)
+ this.notifier.success($localize`Video channel ${videoChannelUpdate.displayName} updated.`)
- 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) {
this.videoChannelService.changeVideoChannelImage(this.videoChannel.name, formData, 'avatar')
- .subscribe(
- data => {
+ .subscribe({
+ next: data => {
this.notifier.success($localize`Avatar changed.`)
this.videoChannel.updateAvatar(data.avatar)
},
- (err: HttpErrorResponse) => genericUploadErrorHandler({
+ error: (err: HttpErrorResponse) => genericUploadErrorHandler({
err,
name: $localize`avatar`,
notifier: this.notifier
})
- )
+ })
}
onAvatarDelete () {
this.videoChannelService.deleteVideoChannelImage(this.videoChannel.name, 'avatar')
- .subscribe(
- data => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Avatar deleted.`)
this.videoChannel.resetAvatar()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
onBannerChange (formData: FormData) {
this.videoChannelService.changeVideoChannelImage(this.videoChannel.name, formData, 'banner')
- .subscribe(
- data => {
+ .subscribe({
+ next: data => {
this.notifier.success($localize`Banner changed.`)
this.videoChannel.updateBanner(data.banner)
},
- (err: HttpErrorResponse) => genericUploadErrorHandler({
+ error: (err: HttpErrorResponse) => genericUploadErrorHandler({
err,
name: $localize`banner`,
notifier: this.notifier
})
- )
+ })
}
onBannerDelete () {
this.videoChannelService.deleteVideoChannelImage(this.videoChannel.name, 'banner')
- .subscribe(
- data => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Banner deleted.`)
this.videoChannel.resetBanner()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
get maxAvatarSize () {
if (res === false) return
this.videoChannelService.removeVideoChannel(videoChannel)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.loadVideoChannels()
this.notifier.success($localize`Video channel ${videoChannel.displayName} deleted.`)
},
- error => this.notifier.error(error.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
private loadVideoChannels () {
onVideosHistoryChange () {
this.userService.updateMyProfile({ videosHistoryEnabled: this.videosHistoryEnabled })
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
const message = this.videosHistoryEnabled === true ?
$localize`Videos history is enabled` :
$localize`Videos history is disabled`
this.authService.refreshUserInformation()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
async deleteHistory () {
if (res !== true) return
this.userHistoryService.deleteUserVideosHistory()
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Videos history deleted`)
this.reloadData()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
const videoChangeOwnership = this.videoChangeOwnership
this.videoOwnershipService
.acceptOwnership(videoChangeOwnership.id, { channelId: channel })
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Ownership accepted`)
if (this.accepted) this.accepted.emit()
this.videoChangeOwnership = undefined
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
refuse (videoChangeOwnership: VideoChangeOwnership) {
this.videoOwnershipService.refuseOwnership(videoChangeOwnership.id)
- .subscribe(
- () => this.reloadData(),
- err => this.notifier.error(err.message)
- )
+ .subscribe({
+ next: () => this.reloadData(),
+ error: err => this.notifier.error(err.message)
+ })
}
protected reloadData () {
return this.videoOwnershipService.getOwnershipChanges(this.pagination, this.sort)
- .subscribe(
- resultList => {
+ .subscribe({
+ next: resultList => {
this.videoChangeOwnerships = resultList.data.map(change => ({
...change,
initiatorAccount: new Account(change.initiatorAccount),
this.totalRecords = resultList.total
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
private loadSubscriptions (more = true) {
this.userSubscriptionService.listSubscriptions({ pagination: this.pagination, search: this.search })
- .subscribe(
- res => {
+ .subscribe({
+ next: res => {
this.videoChannels = more
? this.videoChannels.concat(res.data)
: res.data
this.onDataSubject.next(res.data)
},
- error => this.notifier.error(error.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
protected reloadData () {
this.videoImportService.getMyVideoImports(this.pagination, this.sort)
- .subscribe(
- resultList => {
+ .subscribe({
+ next: resultList => {
this.videoImports = resultList.data
this.totalRecords = resultList.total
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
thumbnailfile: body.thumbnailfile || null
}
- this.videoPlaylistService.createVideoPlaylist(videoPlaylistCreate).subscribe(
- () => {
- this.notifier.success($localize`Playlist ${videoPlaylistCreate.displayName} created.`)
- this.router.navigate([ '/my-library', 'video-playlists' ])
- },
+ this.videoPlaylistService.createVideoPlaylist(videoPlaylistCreate)
+ .subscribe({
+ next: () => {
+ this.notifier.success($localize`Playlist ${videoPlaylistCreate.displayName} created.`)
+ this.router.navigate([ '/my-library', 'video-playlists' ])
+ },
- err => this.error = err.message
- )
+ error: err => this.error = err.message
+ })
}
isCreation () {
this.playlistElements.splice(newIndex, 0, element)
this.videoPlaylistService.reorderPlaylist(this.playlist.id, oldPosition, insertAfter)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.reorderClientPositions()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
onElementRemoved (element: VideoPlaylistElement) {
if (res === false) return
this.videoPlaylistService.removeVideoPlaylist(videoPlaylist)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.router.navigate([ '/my-library', 'video-playlists' ])
this.notifier.success($localize`Playlist ${videoPlaylist.displayName} deleted.`)
},
- error => this.notifier.error(error.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
/**
])
})
)
- .subscribe(
- ([ videoPlaylistToUpdate, videoPlaylistPrivacies]) => {
+ .subscribe({
+ next: ([ videoPlaylistToUpdate, videoPlaylistPrivacies]) => {
this.videoPlaylistToUpdate = videoPlaylistToUpdate
this.videoPlaylistPrivacies = videoPlaylistPrivacies
this.hydrateFormFromPlaylist()
},
- err => this.error = err.message
- )
+ error: err => this.error = err.message
+ })
}
ngOnDestroy () {
thumbnailfile: body.thumbnailfile || undefined
}
- this.videoPlaylistService.updateVideoPlaylist(this.videoPlaylistToUpdate, videoPlaylistUpdate).subscribe(
- () => {
- this.notifier.success($localize`Playlist ${videoPlaylistUpdate.displayName} updated.`)
- this.router.navigate([ '/my-library', 'video-playlists' ])
- },
+ this.videoPlaylistService.updateVideoPlaylist(this.videoPlaylistToUpdate, videoPlaylistUpdate)
+ .subscribe({
+ next: () => {
+ this.notifier.success($localize`Playlist ${videoPlaylistUpdate.displayName} updated.`)
+ this.router.navigate([ '/my-library', 'video-playlists' ])
+ },
- err => this.error = err.message
- )
+ error: err => this.error = err.message
+ })
}
isCreation () {
if (res === false) return
this.videoPlaylistService.removeVideoPlaylist(videoPlaylist)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.videoPlaylists = this.videoPlaylists
.filter(p => p.id !== videoPlaylist.id)
this.notifier.success($localize`Playlist ${videoPlaylist.displayName}} deleted.`)
},
- error => this.notifier.error(error.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
isRegularPlaylist (playlist: VideoPlaylist) {
search (event: { query: string }) {
const query = event.query
this.userService.autocomplete(query)
- .subscribe(
- usernames => this.usernamePropositions = usernames,
+ .subscribe({
+ next: usernames => this.usernamePropositions = usernames,
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
changeOwnership () {
this.videoOwnershipService
.changeOwnership(this.video.id, username)
- .subscribe(
- () => this.notifier.success($localize`Ownership change request sent.`),
+ .subscribe({
+ next: () => this.notifier.success($localize`Ownership change request sent.`),
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
concat(...observables)
.pipe(toArray())
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`${toDeleteVideosIds.length} videos deleted.`)
this.selection = {}
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
async deleteVideo (video: Video) {
if (res === false) return
this.videoService.removeVideo(video.id)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Video ${video.name} deleted.`)
this.removeVideoFromArray(video.id)
},
- error => this.notifier.error(error.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
changeOwnership (video: Video) {
resetPassword () {
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.router.navigate([ '/login' ])
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
isConfirmedPasswordValid () {
ngOnInit () {
this.serverConfig = this.serverService.getHTMLConfig()
- this.subActivatedRoute = this.route.queryParams.subscribe(
- async queryParams => {
- const querySearch = queryParams['search']
- const searchTarget = queryParams['searchTarget']
-
- // Search updated, reset filters
- if (this.currentSearch !== querySearch || searchTarget !== this.advancedSearch.searchTarget) {
- this.resetPagination()
- this.advancedSearch.reset()
-
- this.currentSearch = querySearch || undefined
- this.updateTitle()
- }
+ this.subActivatedRoute = this.route.queryParams
+ .subscribe({
+ next: async queryParams => {
+ const querySearch = queryParams['search']
+ const searchTarget = queryParams['searchTarget']
- this.advancedSearch = new AdvancedSearch(queryParams)
- if (!this.advancedSearch.searchTarget) {
- this.advancedSearch.searchTarget = this.getDefaultSearchTarget()
- }
+ // Search updated, reset filters
+ if (this.currentSearch !== querySearch || searchTarget !== this.advancedSearch.searchTarget) {
+ this.resetPagination()
+ this.advancedSearch.reset()
- this.error = this.checkFieldsAndGetError()
+ this.currentSearch = querySearch || undefined
+ this.updateTitle()
+ }
- // Don't hide filters if we have some of them AND the user just came on the webpage, or we have an error
- this.isSearchFilterCollapsed = !this.error && (this.isInitialLoad === false || !this.advancedSearch.containsValues())
- this.isInitialLoad = false
+ this.advancedSearch = new AdvancedSearch(queryParams)
+ if (!this.advancedSearch.searchTarget) {
+ this.advancedSearch.searchTarget = this.getDefaultSearchTarget()
+ }
- this.search()
- },
+ this.error = this.checkFieldsAndGetError()
- err => this.notifier.error(err.text)
- )
+ // Don't hide filters if we have some of them AND the user just came on the webpage, or we have an error
+ this.isSearchFilterCollapsed = !this.error && (this.isInitialLoad === false || !this.advancedSearch.containsValues())
+ this.isInitialLoad = false
+
+ this.search()
+ },
+
+ error: err => this.notifier.error(err.text)
+ })
this.userService.getAnonymousOrLoggedUser()
.subscribe(user => this.userMiniature = user)
this.getVideoChannelObs(),
this.getVideoPlaylistObs(),
this.getVideosObs()
- ]).subscribe(results => {
- for (const result of results) {
- this.results = this.results.concat(result.data)
- }
+ ]).subscribe({
+ next: results => {
+ for (const result of results) {
+ this.results = this.results.concat(result.data)
+ }
- this.pagination.totalItems = results.reduce((p, r) => p += r.total, 0)
- this.lastSearchTarget = this.advancedSearch.searchTarget
+ this.pagination.totalItems = results.reduce((p, r) => p += r.total, 0)
+ this.lastSearchTarget = this.advancedSearch.searchTarget
- this.hasMoreResults = this.results.length < this.pagination.totalItems
- },
+ this.hasMoreResults = this.results.length < this.pagination.totalItems
+ },
- err => {
- if (this.advancedSearch.searchTarget !== 'search-index') {
- this.notifier.error(err.message)
- return
- }
+ error: err => {
+ if (this.advancedSearch.searchTarget !== 'search-index') {
+ this.notifier.error(err.message)
+ return
+ }
- this.notifier.error(
- $localize`Search index is unavailable. Retrying with instance results instead.`,
- $localize`Search error`
- )
- this.advancedSearch.searchTarget = 'local'
- this.search()
- },
+ this.notifier.error(
+ $localize`Search index is unavailable. Retrying with instance results instead.`,
+ $localize`Search error`
+ )
+ this.advancedSearch.searchTarget = 'local'
+ this.search()
+ },
- () => {
- this.isSearching = false
+ complete: () => {
+ this.isSearching = false
+ }
})
}
'filter:api.signup.registration.create.params'
)
- this.userService.signup(body).subscribe(
- () => {
+ this.userService.signup(body).subscribe({
+ next: () => {
this.signupDone = true
if (this.requiresEmailVerification) {
// Auto login
this.authService.login(body.username, body.password)
- .subscribe(
- () => {
- this.success = $localize`You are now logged in as ${body.username}!`
- },
+ .subscribe({
+ next: () => {
+ 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
+ })
}
}
askSendVerifyEmail () {
const email = this.form.value['verify-email-email']
this.userService.askSendVerifyEmail(email)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`An email with verification link will be sent to ${email}.`)
this.redirectService.redirectToHomepage()
},
- err => {
- this.notifier.error(err.message)
- }
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
verifyEmail () {
this.userService.verifyEmail(this.userId, this.verificationString, this.isPendingEmail)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
if (this.authService.isLoggedIn()) {
this.authService.refreshUserInformation()
}
this.success = true
},
- err => {
+ error: err => {
this.failed = true
this.notifier.error(err.message)
}
- )
+ })
}
}
import { Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main'
import { LiveVideoService } from '@app/shared/shared-video-live'
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'
@Component({
const toPatch = Object.assign({}, video, { privacy: this.firstStepPrivacyId })
this.form.patchValue(toPatch)
- this.liveVideoService.goLive(video).subscribe(
- res => {
- this.videoId = res.video.id
- this.videoUUID = res.video.uuid
- this.isInUpdateForm = true
+ this.liveVideoService.goLive(video)
+ .subscribe({
+ next: res => {
+ this.videoId = res.video.id
+ this.videoUUID = res.video.uuid
+ this.isInUpdateForm = true
- this.firstStepDone.emit(name)
+ this.firstStepDone.emit(name)
- this.fetchVideoLive()
- },
+ this.fetchVideoLive()
+ },
+
+ error: err => {
+ this.firstStepError.emit()
- err => {
- this.firstStepError.emit()
+ let message = err.message
- let message = err.message
+ const error = err.body as PeerTubeProblemDocument
- const error = err.body as PeerTubeProblemDocument
+ if (error?.code === ServerErrorCode.MAX_INSTANCE_LIVES_LIMIT_REACHED) {
+ message = $localize`Cannot create live because this instance have too many created lives`
+ } else if (error?.code === ServerErrorCode.MAX_USER_LIVES_LIMIT_REACHED) {
+ message = $localize`Cannot create live because you created too many lives`
+ }
- if (error?.code === ServerErrorCode.MAX_INSTANCE_LIVES_LIMIT_REACHED) {
- message = $localize`Cannot create live because this instance have too many created lives`
- } else if (error?.code === ServerErrorCode.MAX_USER_LIVES_LIMIT_REACHED) {
- message = $localize`Cannot create live because you created too many lives`
+ this.notifier.error(message)
}
-
- this.notifier.error(message)
- }
- )
+ })
}
updateSecondStep () {
this.updateVideoAndCaptions(video),
this.liveVideoService.updateLive(this.videoId, liveVideoUpdate)
- ]).subscribe(
- () => {
+ ]).subscribe({
+ next: () => {
this.notifier.success($localize`Live published.`)
this.router.navigateByUrl(Video.buildWatchUrl(video))
},
- err => {
+ error: err => {
this.error = err.message
scrollToTop()
console.error(err)
}
- )
+ })
}
getMaxLiveDuration () {
private fetchVideoLive () {
this.liveVideoService.getVideoLive(this.videoId)
- .subscribe(
- liveVideo => {
+ .subscribe({
+ next: liveVideo => {
this.liveVideo = liveVideo
},
- err => {
+ error: err => {
this.firstStepError.emit()
this.notifier.error(err.message)
}
- )
+ })
}
}
this.loadingBar.useRef().start()
- this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate).subscribe(
- res => {
- this.loadingBar.useRef().complete()
- this.firstStepDone.emit(res.video.name)
- this.isImportingVideo = false
- this.hasImportedVideo = true
-
- this.video = new VideoEdit(Object.assign(res.video, {
- commentsEnabled: videoUpdate.commentsEnabled,
- downloadEnabled: videoUpdate.downloadEnabled,
- privacy: { id: this.firstStepPrivacyId },
- support: null,
- thumbnailUrl: null,
- previewUrl: null
- }))
-
- hydrateFormFromVideo(this.form, this.video, false)
- },
-
- err => {
- this.loadingBar.useRef().complete()
- this.isImportingVideo = false
- this.firstStepError.emit()
-
- let message = err.message
-
- const error = err.body as PeerTubeProblemDocument
- if (error?.code === ServerErrorCode.INCORRECT_FILES_IN_TORRENT) {
- message = $localize`Torrents with only 1 file are supported.`
- }
+ this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate)
+ .subscribe({
+ next: res => {
+ this.loadingBar.useRef().complete()
+ this.firstStepDone.emit(res.video.name)
+ this.isImportingVideo = false
+ this.hasImportedVideo = true
+
+ this.video = new VideoEdit(Object.assign(res.video, {
+ commentsEnabled: videoUpdate.commentsEnabled,
+ downloadEnabled: videoUpdate.downloadEnabled,
+ privacy: { id: this.firstStepPrivacyId },
+ support: null,
+ thumbnailUrl: null,
+ previewUrl: null
+ }))
+
+ hydrateFormFromVideo(this.form, this.video, false)
+ },
+
+ error: err => {
+ this.loadingBar.useRef().complete()
+ this.isImportingVideo = false
+ this.firstStepError.emit()
+
+ let message = err.message
+
+ const error = err.body as PeerTubeProblemDocument
+ if (error?.code === ServerErrorCode.INCORRECT_FILES_IN_TORRENT) {
+ message = $localize`Torrents with only 1 file are supported.`
+ }
- this.notifier.error(message)
- }
- )
+ this.notifier.error(message)
+ }
+ })
}
updateSecondStep () {
// Update the video
this.updateVideoAndCaptions(this.video)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.isUpdatingVideo = false
this.notifier.success($localize`Video to import updated.`)
this.router.navigate([ '/my-library', 'video-imports' ])
},
- err => {
+ error: err => {
this.error = err.message
scrollToTop()
console.error(err)
}
- )
+ })
}
}
import { FormValidatorService } from '@app/shared/shared-forms'
import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main'
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 { VideoSend } from './video-send'
)
})
)
- .subscribe(
- ({ video, videoCaptions }) => {
+ .subscribe({
+ next: ({ video, videoCaptions }) => {
this.loadingBar.useRef().complete()
this.firstStepDone.emit(video.name)
this.isImportingVideo = false
hydrateFormFromVideo(this.form, this.video, true)
},
- err => {
+ error: err => {
this.loadingBar.useRef().complete()
this.isImportingVideo = false
this.firstStepError.emit()
this.notifier.error(err.message)
}
- )
+ })
}
updateSecondStep () {
// Update the video
this.updateVideoAndCaptions(this.video)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.isUpdatingVideo = false
this.notifier.success($localize`Video to import updated.`)
this.router.navigate([ '/my-library', 'video-imports' ])
},
- err => {
+ error: err => {
this.error = err.message
scrollToTop()
console.error(err)
}
- )
+ })
}
}
this.isUpdatingVideo = true
this.updateVideoAndCaptions(video)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.isUpdatingVideo = false
this.isUploadingVideo = false
this.router.navigateByUrl(Video.buildWatchUrl(video))
},
- err => {
+ error: err => {
this.error = err.message
scrollToTop()
console.error(err)
}
- )
+ })
}
private getInputVideoFile () {
this.route.data
.pipe(map(data => data.videoData))
- .subscribe(({ video, videoChannels, videoCaptions, liveVideo }) => {
- this.video = new VideoEdit(video)
- this.videoDetails = video
-
- this.userVideoChannels = videoChannels
- this.videoCaptions = videoCaptions
- this.liveVideo = liveVideo
-
- this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
-
- // FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout
- setTimeout(() => {
- hydrateFormFromVideo(this.form, this.video, true)
-
- if (this.liveVideo) {
- this.form.patchValue({
- saveReplay: this.liveVideo.saveReplay,
- permanentLive: this.liveVideo.permanentLive
- })
- }
- })
- },
+ .subscribe({
+ next: ({ video, videoChannels, videoCaptions, liveVideo }) => {
+ this.video = new VideoEdit(video)
+ this.videoDetails = video
+
+ this.userVideoChannels = videoChannels
+ this.videoCaptions = videoCaptions
+ this.liveVideo = liveVideo
+
+ this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
+
+ // FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout
+ setTimeout(() => {
+ hydrateFormFromVideo(this.form, this.video, true)
+
+ if (this.liveVideo) {
+ this.form.patchValue({
+ saveReplay: this.liveVideo.saveReplay,
+ permanentLive: this.liveVideo.permanentLive
+ })
+ }
+ })
+ },
- err => {
- console.error(err)
- this.notifier.error(err.message)
- }
- )
+ error: err => {
+ console.error(err)
+ this.notifier.error(err.message)
+ }
+ })
}
@HostListener('window:beforeunload', [ '$event' ])
return this.liveVideoService.updateLive(this.video.id, liveVideoUpdate)
})
)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.updateDone = true
this.isUpdatingVideo = false
this.loadingBar.useRef().complete()
this.router.navigateByUrl(Video.buildWatchUrl(this.video))
},
- err => {
+ error: err => {
this.loadingBar.useRef().complete()
this.isUpdatingVideo = false
this.notifier.error(err.message)
console.error(err)
}
- )
+ })
}
hydratePluginFieldsFromVideo () {
if (this.isUserLoggedIn === false) return
this.videoService.getUserVideoRating(this.video.id)
- .subscribe(
- ratingObject => {
+ .subscribe({
+ next: ratingObject => {
if (!ratingObject) return
this.userRating = ratingObject.rating
this.userRatingLoaded.emit(this.userRating)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
private setRating (nextRating: UserVideoRateType) {
}
ratingMethods[nextRating].call(this.videoService, this.video.id)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
// Update the video like attribute
this.updateVideoRating(this.userRating, nextRating)
this.userRating = nextRating
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) {
obs = this.addCommentThread(commentCreate)
}
- obs.subscribe(
- comment => {
+ obs.subscribe({
+ next: comment => {
this.addingComment = false
this.commentCreated.emit(comment)
this.form.reset()
},
- err => {
+ error: err => {
this.addingComment = false
this.notifier.error(err.text)
}
- )
+ })
}
isAddButtonDisplayed () {
const user = this.authService.getUser()
if (user.hasRight(UserRight.MANAGE_USERS)) {
this.userService.getUserWithCache(account.userId)
- .subscribe(
- user => this.commentUser = user,
+ .subscribe({
+ next: user => this.commentUser = user,
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
'filter:api.video-watch.video-thread-replies.list.result'
)
- obs.subscribe(
- res => {
- this.threadComments[commentId] = res
- this.threadLoading[commentId] = false
- this.hooks.runAction('action:video-watch.video-thread-replies.loaded', 'video-watch', { data: res })
+ obs.subscribe({
+ next: res => {
+ this.threadComments[commentId] = res
+ this.threadLoading[commentId] = false
+ this.hooks.runAction('action:video-watch.video-thread-replies.loaded', 'video-watch', { data: res })
- if (highlightThread) {
- this.highlightedThread = new VideoComment(res.comment)
+ if (highlightThread) {
+ this.highlightedThread = new VideoComment(res.comment)
- // Scroll to the highlighted thread
- setTimeout(() => this.commentHighlightBlock.nativeElement.scrollIntoView(), 0)
- }
- },
+ // Scroll to the highlighted thread
+ setTimeout(() => this.commentHighlightBlock.nativeElement.scrollIntoView(), 0)
+ }
+ },
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
loadMoreThreads () {
'filter:api.video-watch.video-threads.list.result'
)
- obs.subscribe(
- res => {
+ obs.subscribe({
+ next: res => {
this.comments = this.comments.concat(res.data)
this.componentPagination.totalItems = res.total
this.totalNotDeletedComments = res.totalNotDeletedComments
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) {
if (res === false) return false
this.videoCommentService.deleteVideoComment(commentToDelete.videoId, commentToDelete.id)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
if (this.highlightedThread?.id === commentToDelete.id) {
commentToDelete = this.comments.find(c => c.id === commentToDelete.id)
this.softDeleteComment(commentToDelete)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
return true
}
this.descriptionLoading = true
this.videoService.loadCompleteDescription(this.video.descriptionPath)
- .subscribe(
- description => {
+ .subscribe({
+ next: description => {
this.completeDescriptionShown = true
this.descriptionLoading = false
this.updateVideoDescription(this.completeVideoDescription)
},
- error => {
+ error: err => {
this.descriptionLoading = false
- this.notifier.error(error.message)
+ this.notifier.error(err.message)
}
- )
+ })
}
onTimestampClicked (timestamp: number) {
-
import { Component, EventEmitter, Input, Output } from '@angular/core'
import { Router } from '@angular/router'
import { AuthService, ComponentPagination, LocalStorageService, Notifier, SessionStorageService, UserService } from '@app/core'
autoPlayNextVideoPlaylist: this.autoPlayNextVideoPlaylist
}
- this.userService.updateMyProfile(details).subscribe(
- () => {
- this.auth.refreshUserInformation()
- },
- err => this.notifier.error(err.message)
- )
+ this.userService.updateMyProfile(details)
+ .subscribe({
+ next: () => {
+ this.auth.refreshUserInformation()
+ },
+
+ error: err => this.notifier.error(err.message)
+ })
}
}
autoPlayNextVideo: this.autoPlayNextVideo
}
- this.userService.updateMyProfile(details).subscribe(
- () => {
- this.authService.refreshUserInformation()
- },
- err => this.notifier.error(err.message)
- )
+ this.userService.updateMyProfile(details)
+ .subscribe({
+ next: () => {
+ this.authService.refreshUserInformation()
+ },
+
+ error: err => this.notifier.error(err.message)
+ })
}
}
}
)
forkJoin([ videoObs, this.videoCaptionService.listCaptions(videoId)])
- .subscribe(
- ([ video, captionsResult ]) => {
+ .subscribe({
+ next: ([ video, captionsResult ]) => {
const queryParams = this.route.snapshot.queryParams
const urlOptions = {
.catch(err => this.handleGlobalError(err))
},
- err => this.handleRequestError(err)
- )
+ error: err => this.handleRequestError(err)
+ })
}
private loadPlaylist (playlistId: string) {
if (this.isSameElement(this.playlist, playlistId)) return
this.playlistService.getVideoPlaylist(playlistId)
- .subscribe(
- playlist => {
+ .subscribe({
+ next: playlist => {
this.playlist = playlist
this.videoWatchPlaylist.loadPlaylistElements(playlist, !this.playlistPosition, this.playlistPosition)
},
- err => this.handleRequestError(err)
- )
+ error: err => this.handleRequestError(err)
+ })
}
private isSameElement (element: VideoDetails | VideoPlaylist, newId: string) {
this.isLoading = true
this.overviewService.getVideosOverview(this.currentPage)
- .subscribe(
- overview => {
+ .subscribe({
+ next: overview => {
this.isLoading = false
if (overview.tags.length === 0 && overview.channels.length === 0 && overview.categories.length === 0) {
this.overviews.push(overview)
},
- err => {
+ error: err => {
this.notifier.error(err.message)
this.isLoading = false
}
- )
+ })
}
}
this.authService.userInformationLoaded
.pipe(switchMap(() => this.scopedTokensService.getScopedTokens()))
- .subscribe(
- tokens => {
+ .subscribe({
+ next: tokens => {
const feeds = this.videoService.getVideoSubscriptionFeedUrls(user.account.id, tokens.feedToken)
feedUrl = feedUrl + feeds.find(f => f.format === FeedFormat.RSS).url
})
},
- err => {
+ error: err => {
this.notifier.error(err.message)
}
- )
+ })
}
ngOnDestroy () {
// Fetch the client_id/client_secret
this.http.get<OAuthClientLocal>(AuthService.BASE_CLIENT_URL)
.pipe(catchError(res => this.restExtractor.handleError(res)))
- .subscribe(
- res => {
+ .subscribe({
+ next: res => {
this.clientId = res.client_id
this.clientSecret = res.client_secret
console.log('Client credentials loaded.')
},
- error => {
- let errorMessage = error.message
+ error: err => {
+ let errorMessage = err.message
- if (error.status === HttpStatusCode.FORBIDDEN_403) {
- errorMessage = $localize`Cannot retrieve OAuth Client credentials: ${error.text}.
+ if (err.status === HttpStatusCode.FORBIDDEN_403) {
+ errorMessage = $localize`Cannot retrieve OAuth Client credentials: ${err.text}.
Ensure you have correctly configured PeerTube (config/ directory), in particular the "webserver" section.`
}
// We put a bigger timeout: this is an important message
this.notifier.error(errorMessage, $localize`Error`, 7000)
}
- )
+ })
}
getRefreshToken () {
const headers = new HttpHeaders().set('Authorization', authHeaderValue)
this.http.post<{ redirectUrl?: string }>(AuthService.BASE_REVOKE_TOKEN_URL, {}, { headers })
- .subscribe(
- res => {
- if (res.redirectUrl) {
- window.location.href = res.redirectUrl
- }
- },
+ .subscribe({
+ next: res => {
+ if (res.redirectUrl) {
+ window.location.href = res.redirectUrl
+ }
+ },
- err => console.error(err)
- )
+ error: err => console.error(err)
+ })
this.user = null
this.logout()
this.router.navigate([ '/login' ])
- return observableThrowError({
+ return observableThrowError(() => ({
error: $localize`You need to reconnect.`
- })
+ }))
}),
share()
)
}
this.mergeUserInformation(obj)
- .subscribe(
- res => {
+ .subscribe({
+ next: res => {
this.user.patch(res)
this.user.save()
this.userInformationLoaded.next(true)
}
- )
+ })
}
private mergeUserInformation (obj: UserLoginWithUsername): Observable<UserLoginWithUserInformation> {
-import { first } from 'rxjs/operators'
+import { firstValueFrom, Subject } from 'rxjs'
import { Injectable } from '@angular/core'
-import { Subject } from 'rxjs'
type ConfirmOptions = {
title: string
confirm (message: string, title = '', confirmButtonText?: string) {
this.showConfirm.next({ title, message, confirmButtonText })
- return this.confirmResponse.asObservable()
- .pipe(first())
- .toPromise()
+ return firstValueFrom(this.confirmResponse.asObservable())
}
confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '', confirmButtonText?: string) {
this.showConfirm.next({ title, message, inputLabel, expectedInputValue, confirmButtonText })
- return this.confirmResponse.asObservable()
- .pipe(first())
- .toPromise()
+ return firstValueFrom(this.confirmResponse.asObservable())
}
}
-import { Observable, of } from 'rxjs'
+import { firstValueFrom, Observable, of } from 'rxjs'
import { catchError, map, shareReplay } from 'rxjs/operators'
import { HttpClient } from '@angular/common/http'
import { Inject, Injectable, LOCALE_ID, NgZone } from '@angular/core'
getSettings: () => {
const path = PluginService.BASE_PLUGIN_API_URL + '/' + npmName + '/public-settings'
- return this.authHttp.get<PublicServerSetting>(path)
+ const obs = this.authHttp.get<PublicServerSetting>(path)
.pipe(
map(p => p.publicSettings),
catchError(res => this.restExtractor.handleError(res))
)
- .toPromise()
+
+ return firstValueFrom(obs)
},
getServerConfig: () => {
- return this.server.getConfig()
+ const obs = this.server.getConfig()
.pipe(catchError(res => this.restExtractor.handleError(res)))
- .toPromise()
+
+ return firstValueFrom(obs)
},
isLoggedIn: () => {
},
translate: (value: string) => {
- return this.translationsObservable
+ const obs = this.translationsObservable
.pipe(map(allTranslations => allTranslations[npmName]))
.pipe(map(translations => peertubeTranslate(value, translations)))
- .toPromise()
+
+ return firstValueFrom(obs)
}
}
}
errorObj.body = err.error
}
- return observableThrowError(errorObj)
+ return observableThrowError(() => errorObj)
}
redirectTo404IfNotFound (obj: { status: number }, type: 'video' | 'other', status = [ HttpStatusCode.NOT_FOUND_404 ]) {
this.router.navigate([ '/404' ], { state: { type, obj }, skipLocationChange: true })
}
- return observableThrowError(obj)
+ return observableThrowError(() => obj)
}
}
ngOnInit () {
this.userNotificationService.countUnreadNotifications()
- .subscribe(
- result => {
+ .subscribe({
+ next: result => {
this.unreadNotifications = Math.min(result, 99) // Limit number to 99
this.subscribeToNotifications()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
this.routeSub = this.router.events
.pipe(filter(event => event instanceof NavigationEnd))
peertubeLocalStorage.setItem(this.LOCAL_STORAGE_KEYS.NO_INSTANCE_CONFIG_WARNING_MODAL, 'true')
this.userService.updateMyProfile({ noInstanceConfigWarningModal: true })
- .subscribe(
- () => console.log('We will not open the instance config warning modal again.'),
+ .subscribe({
+ 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)
+ })
}
}
ngOnInit () {
this.user = this.userService.getAnonymousUser()
this.localStorageService.watch()
- .subscribe(
- () => this.user = this.userService.getAnonymousUser()
- )
+ .subscribe({
+ next: () => this.user = this.userService.getAnonymousUser()
+ })
this.userInformationLoaded.next(true)
this.authService.loginChangedSource
.pipe(filter(status => status !== AuthStatus.LoggedIn))
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.user = this.userService.getAnonymousUser()
this.userInformationLoaded.next(true)
}
- )
+ })
}
isUserLoggedIn () {
peertubeLocalStorage.setItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL, 'true')
this.userService.updateMyProfile({ noWelcomeModal: true })
- .subscribe(
- () => console.log('We will not open the welcome modal again.'),
+ .subscribe({
+ next: () => console.log('We will not open the welcome modal again.'),
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
const res = await this.confirmService.confirm($localize`Do you really want to delete this abuse report?`, $localize`Delete`)
if (res === false) return
- this.abuseService.removeAbuse(abuse).subscribe(
- () => {
- this.notifier.success($localize`Abuse deleted.`)
- this.reloadData()
- },
+ this.abuseService.removeAbuse(abuse)
+ .subscribe({
+ next: () => {
+ this.notifier.success($localize`Abuse deleted.`)
+ this.reloadData()
+ },
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
updateAbuseState (abuse: AdminAbuse, state: AbuseState) {
this.abuseService.updateAbuse(abuse, { state })
- .subscribe(
- () => this.reloadData(),
+ .subscribe({
+ next: () => this.reloadData(),
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
onCountMessagesUpdated (event: { abuseId: number, countMessages: number }) {
? this.abuseService.getAdminAbuses(options)
: this.abuseService.getUserAbuses(options)
- return observable.subscribe(
- async resultList => {
- this.totalRecords = resultList.total
+ return observable.subscribe({
+ next: async resultList => {
+ this.totalRecords = resultList.total
- this.abuses = []
+ this.abuses = []
- for (const a of resultList.data) {
- const abuse = a as ProcessedAbuse
+ for (const a of resultList.data) {
+ const abuse = a as ProcessedAbuse
- abuse.reasonHtml = await this.toHtml(abuse.reason)
+ abuse.reasonHtml = await this.toHtml(abuse.reason)
- if (abuse.moderationComment) {
- abuse.moderationCommentHtml = await this.toHtml(abuse.moderationComment)
- }
+ if (abuse.moderationComment) {
+ abuse.moderationCommentHtml = await this.toHtml(abuse.moderationComment)
+ }
- if (abuse.video) {
- abuse.embedHtml = this.sanitizer.bypassSecurityTrustHtml(this.getVideoEmbed(abuse))
+ if (abuse.video) {
+ abuse.embedHtml = this.sanitizer.bypassSecurityTrustHtml(this.getVideoEmbed(abuse))
- if (abuse.video.channel?.ownerAccount) {
- abuse.video.channel.ownerAccount = new Account(abuse.video.channel.ownerAccount)
- }
+ if (abuse.video.channel?.ownerAccount) {
+ abuse.video.channel.ownerAccount = new Account(abuse.video.channel.ownerAccount)
}
+ }
- if (abuse.comment) {
- if (abuse.comment.deleted) {
- abuse.truncatedCommentHtml = abuse.commentHtml = $localize`Deleted comment`
- } else {
- const truncated = truncate(abuse.comment.text, { length: 100 })
- abuse.truncatedCommentHtml = await this.markdownRenderer.textMarkdownToHTML(truncated, true)
- abuse.commentHtml = await this.markdownRenderer.textMarkdownToHTML(abuse.comment.text, true)
- }
+ if (abuse.comment) {
+ if (abuse.comment.deleted) {
+ abuse.truncatedCommentHtml = abuse.commentHtml = $localize`Deleted comment`
+ } else {
+ const truncated = truncate(abuse.comment.text, { length: 100 })
+ abuse.truncatedCommentHtml = await this.markdownRenderer.textMarkdownToHTML(truncated, true)
+ abuse.commentHtml = await this.markdownRenderer.textMarkdownToHTML(abuse.comment.text, true)
}
+ }
- if (abuse.reporterAccount) {
- abuse.reporterAccount = new Account(abuse.reporterAccount)
- }
+ if (abuse.reporterAccount) {
+ abuse.reporterAccount = new Account(abuse.reporterAccount)
+ }
- if (abuse.flaggedAccount) {
- abuse.flaggedAccount = new Account(abuse.flaggedAccount)
- }
+ if (abuse.flaggedAccount) {
+ abuse.flaggedAccount = new Account(abuse.flaggedAccount)
+ }
- if (abuse.updatedAt === abuse.createdAt) delete abuse.updatedAt
+ if (abuse.updatedAt === abuse.createdAt) delete abuse.updatedAt
- this.abuses.push(abuse)
- }
- },
+ this.abuses.push(abuse)
+ }
+ },
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
private buildInternalActions (): DropdownAction<ProcessedAbuse>[] {
isDisplayed: abuse => abuse.video && !abuse.video.deleted && !abuse.video.blacklisted,
handler: abuse => {
this.videoBlocklistService.blockVideo(abuse.video.id, undefined, abuse.video.channel.isLocal)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Video blocked.`)
this.updateAbuseState(abuse, AbuseState.ACCEPTED)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
},
{
isDisplayed: abuse => abuse.video && !abuse.video.deleted && abuse.video.blacklisted,
handler: abuse => {
this.videoBlocklistService.unblockVideo(abuse.video.id)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Video unblocked.`)
this.updateAbuseState(abuse, AbuseState.ACCEPTED)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
},
{
if (res === false) return
this.videoService.removeVideo(abuse.video.id)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Video deleted.`)
this.updateAbuseState(abuse, AbuseState.ACCEPTED)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
]
if (res === false) return
this.commentService.deleteVideoComment(abuse.comment.video.id, abuse.comment.id)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Comment deleted.`)
this.updateAbuseState(abuse, AbuseState.ACCEPTED)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
]
private muteAccountHelper (account: Account) {
this.blocklistService.blockAccountByInstance(account)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Account ${account.nameWithHost} muted by the instance.`)
account.mutedByInstance = true
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
private muteServerHelper (host: string) {
this.blocklistService.blockServerByInstance(host)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Server ${host} muted by the instance.`)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
private toHtml (text: string) {
this.sendingMessage = true
this.abuseService.addAbuseMessage(this.abuse, this.form.value['message'])
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.form.reset()
this.sendingMessage = false
this.countMessagesUpdated.emit({ abuseId: this.abuse.id, countMessages: this.abuseMessages.length + 1 })
this.loadMessages()
},
- err => {
+ error: err => {
this.sendingMessage = false
console.error(err)
this.notifier.error('Sorry but you cannot send this message. Please retry later')
}
- )
+ })
}
deleteMessage (abuseMessage: AbuseMessage) {
this.abuseService.deleteAbuseMessage(this.abuse, abuseMessage)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.countMessagesUpdated.emit({ abuseId: this.abuse.id, countMessages: this.abuseMessages.length - 1 })
this.abuseMessages = this.abuseMessages.filter(m => m.id !== abuseMessage.id)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
isMessageByMe (abuseMessage: AbuseMessage) {
private loadMessages () {
this.abuseService.listAbuseMessages(this.abuse)
- .subscribe(
- async res => {
+ .subscribe({
+ next: async res => {
this.abuseMessages = []
for (const m of res.data) {
})
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
const moderationComment: string = this.form.value[ 'moderationComment' ]
this.abuseService.updateAbuse(this.abuseToComment, { moderationComment })
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Comment updated.`)
this.commentUpdated.emit(moderationComment)
this.hide()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
-import { first } from 'rxjs/operators'
+import { firstValueFrom } from 'rxjs'
import { ComponentRef, Injectable } from '@angular/core'
import { MarkdownService } from '@app/core'
import {
const component = this.execAngularBuilder(selector, e)
if (component.instance.loaded) {
- const p = component.instance.loaded.pipe(first()).toPromise()
+ const p = firstValueFrom(component.instance.loaded)
loadedPromises.push(p)
}
tap(html => this.descriptionHTML = html),
switchMap(() => this.loadVideosObservable()),
finalize(() => this.loaded.emit(true))
- ).subscribe(
- ({ total, data }) => {
+ ).subscribe({
+ next: ({ total, data }) => {
this.totalVideos = total
this.video = data[0]
},
- err => this.notifier.error($localize`Error in channel miniature component: ${err.message}`)
- )
+ error: err => this.notifier.error($localize`Error in channel miniature component: ${err.message}`)
+ })
}
getVideoChannelLink () {
ngOnInit () {
this.findInBulkService.getPlaylist(this.uuid)
.pipe(finalize(() => this.loaded.emit(true)))
- .subscribe(
- playlist => this.playlist = playlist,
+ .subscribe({
+ next: playlist => this.playlist = playlist,
- err => this.notifier.error($localize`Error in playlist miniature component: ${err.message}`)
- )
+ error: err => this.notifier.error($localize`Error in playlist miniature component: ${err.message}`)
+ })
}
}
this.findInBulk.getVideo(this.uuid)
.pipe(finalize(() => this.loaded.emit(true)))
- .subscribe(
- video => this.video = video,
+ .subscribe({
+ next: video => this.video = video,
- err => this.notifier.error($localize`Error in video miniature component: ${err.message}`)
- )
+ error: err => this.notifier.error($localize`Error in video miniature component: ${err.message}`)
+ })
}
}
return this.getVideosObservable()
.pipe(finalize(() => this.loaded.emit(true)))
- .subscribe(
- ({ data }) => this.videos = data,
+ .subscribe({
+ next: ({ data }) => this.videos = data,
- err => this.notifier.error($localize`Error in videos list component: ${err.message}`)
- )
+ error: err => this.notifier.error($localize`Error in videos list component: ${err.message}`)
+ })
}
getVideosObservable () {
ngOnInit (): void {
this.instanceService.getAbout()
- .subscribe(
- async about => {
+ .subscribe({
+ next: async about => {
this.about = about
this.aboutHtml = await this.instanceService.buildHtml(about)
this.init.emit(this)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
getAdministratorsPanel () {
return this.handleNotAuthenticated(err)
}
- return observableThrowError(err)
+ return observableThrowError(() => err)
})
)
}
}
this.userNotificationService.listMyNotifications(options)
- .subscribe(
- result => {
+ .subscribe({
+ next: result => {
this.notifications = reset ? result.data : this.notifications.concat(result.data)
this.componentPagination.totalItems = result.total
this.onDataSubject.next(result.data)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
onNearOfBottom () {
if (notification.read) return
this.userNotificationService.markAsRead(notification)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
notification.read = true
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
markAllAsRead () {
this.userNotificationService.markAllAsRead()
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
for (const notification of this.notifications) {
notification.read = true
}
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
changeSortColumn (column: string) {
search: this.search
})
- return operation.subscribe(
- resultList => {
+ return operation.subscribe({
+ next: resultList => {
this.blockedAccounts = resultList.data
this.totalRecords = resultList.total
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
account: {
id: this.account.id
}
- }).subscribe(
- () => {
+ }).subscribe({
+ next: () => {
this.notifier.success($localize`Account reported.`)
this.hide()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
isRemote () {
comment: {
id: this.comment.id
}
- }).subscribe(
- () => {
+ }).subscribe({
+ next: () => {
this.notifier.success($localize`Comment reported.`)
this.hide()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
isRemote () {
startAt: hasStart && startAt ? startAt : undefined,
endAt: hasEnd && endAt ? endAt : undefined
}
- }).subscribe(
- () => {
+ }).subscribe({
+ next: () => {
this.notifier.success($localize`Video reported.`)
this.hide()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
isRemote () {
search: this.search
})
- return operation.subscribe(
- resultList => {
+ return operation.subscribe({
+ next: resultList => {
this.blockedServers = resultList.data
this.totalRecords = resultList.total
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
const reason = this.form.value['reason'] || undefined
this.userService.banUsers(this.usersToBan, reason)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
const message = Array.isArray(this.usersToBan)
? $localize`${this.usersToBan.length} users banned.`
: $localize`User ${this.usersToBan.username} banned.`
this.hide()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
if (res === false) return
this.userService.unbanUsers(user)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`User ${user.username} unbanned.`)
this.userChanged.emit()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
async removeUser (user: User) {
const res = await this.confirmService.confirm(message, $localize`Delete`)
if (res === false) return
- this.userService.removeUser(user).subscribe(
- () => {
- this.notifier.success($localize`User ${user.username} deleted.`)
- this.userDeleted.emit()
- },
+ this.userService.removeUser(user)
+ .subscribe({
+ next: () => {
+ this.notifier.success($localize`User ${user.username} deleted.`)
+ this.userDeleted.emit()
+ },
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
setEmailAsVerified (user: User) {
- this.userService.updateUser(user.id, { emailVerified: true }).subscribe(
- () => {
- this.notifier.success($localize`User ${user.username} email set as verified`)
- this.userChanged.emit()
- },
-
- err => this.notifier.error(err.message)
- )
+ this.userService.updateUser(user.id, { emailVerified: true })
+ .subscribe({
+ next: () => {
+ this.notifier.success($localize`User ${user.username} email set as verified`)
+ this.userChanged.emit()
+ },
+
+ error: err => this.notifier.error(err.message)
+ })
}
blockAccountByUser (account: Account) {
this.blocklistService.blockAccountByUser(account)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Account ${account.nameWithHost} muted.`)
this.account.mutedByUser = true
this.userChanged.emit()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
unblockAccountByUser (account: Account) {
this.blocklistService.unblockAccountByUser(account)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Account ${account.nameWithHost} unmuted.`)
this.account.mutedByUser = false
this.userChanged.emit()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
blockServerByUser (host: string) {
this.blocklistService.blockServerByUser(host)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Instance ${host} muted.`)
this.account.mutedServerByUser = true
this.userChanged.emit()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
unblockServerByUser (host: string) {
this.blocklistService.unblockServerByUser(host)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Instance ${host} unmuted.`)
this.account.mutedServerByUser = false
this.userChanged.emit()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
blockAccountByInstance (account: Account) {
this.blocklistService.blockAccountByInstance(account)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Account ${account.nameWithHost} muted by the instance.`)
this.account.mutedByInstance = true
this.userChanged.emit()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
unblockAccountByInstance (account: Account) {
this.blocklistService.unblockAccountByInstance(account)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Account ${account.nameWithHost} unmuted by the instance.`)
this.account.mutedByInstance = false
this.userChanged.emit()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
blockServerByInstance (host: string) {
this.blocklistService.blockServerByInstance(host)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Instance ${host} muted by the instance.`)
this.account.mutedServerByInstance = true
this.userChanged.emit()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
unblockServerByInstance (host: string) {
this.blocklistService.unblockServerByInstance(host)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Instance ${host} unmuted by the instance.`)
this.account.mutedServerByInstance = false
this.userChanged.emit()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
async bulkRemoveCommentsOf (body: BulkRemoveCommentsOfBody) {
if (res === false) return
this.bulkService.removeCommentsOf(body)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Will remove comments of this account (may take several minutes).`)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
getRouterUserEditLink (user: User) {
const unfederate = this.video.isLocal ? this.form.value[ 'unfederate' ] : undefined
this.videoBlocklistService.blockVideo(this.video.id, reason, unfederate)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Video blocked.`)
this.hide()
this.videoBlocked.emit()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
import * as debug from 'debug'
-import { Observable, Subject, throwError } from 'rxjs'
+import { Observable, Subject } from 'rxjs'
import { first, map } from 'rxjs/operators'
import { Injectable, NgZone } from '@angular/core'
import { buildBulkObservable } from '@app/helpers'
}
if (this.authService.isLoggedIn()) {
- this.userService.updateMyProfile(details).subscribe(
- () => {
- this.authService.refreshUserInformation()
-
- if (this.notifyOnUpdate) this.notifier.success($localize`Interface settings updated.`)
- },
-
- err => this.notifier.error(err.message)
- )
- } else {
- this.userService.updateMyAnonymousProfile(details)
- if (this.notifyOnUpdate) this.notifier.success($localize`Interface settings updated.`)
+ this.userService.updateMyProfile(details)
+ .subscribe({
+ next: () => {
+ this.authService.refreshUserInformation()
+
+ if (this.notifyOnUpdate) this.notifier.success($localize`Interface settings updated.`)
+ },
+
+ error: err => this.notifier.error(err.message)
+ })
+
+ return
}
+
+ this.userService.updateMyAnonymousProfile(details)
+ if (this.notifyOnUpdate) this.notifier.success($localize`Interface settings updated.`)
}
}
}
private updateLoggedProfile (details: UserUpdateMe) {
- this.userService.updateMyProfile(details).subscribe(
- () => {
- this.authService.refreshUserInformation()
+ this.userService.updateMyProfile(details)
+ .subscribe({
+ next: () => {
+ this.authService.refreshUserInformation()
- if (this.notifyOnUpdate) this.notifier.success($localize`Video settings updated.`)
- },
+ if (this.notifyOnUpdate) this.notifier.success($localize`Video settings updated.`)
+ },
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
private updateAnonymousProfile (details: UserUpdateMe) {
.map(handle => this.userSubscriptionService.addSubscription(handle))
forkJoin(observableBatch)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success(
this.account
? $localize`Subscribed to all current channels of ${this.account.displayName}. You will be notified of all their new videos.`
)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
unsubscribe () {
merge(
this.userSubscriptionService.listenToSubscriptionCacheChange(handle),
this.userSubscriptionService.doesSubscriptionExist(handle)
- ).subscribe(
- res => this.subscribed.set(handle, res),
+ ).subscribe({
+ next: res => this.subscribed.set(handle, res),
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}
}
}
loadMoreVideos (reset = false) {
- this.getVideosObservable(this.pagination.currentPage).subscribe(
- ({ data }) => {
- this.hasDoneFirstQuery = true
- this.lastQueryLength = data.length
+ this.getVideosObservable(this.pagination.currentPage)
+ .subscribe({
+ next: ({ data }) => {
+ this.hasDoneFirstQuery = true
+ this.lastQueryLength = data.length
- if (reset) this.videos = []
- this.videos = this.videos.concat(data)
+ if (reset) this.videos = []
+ this.videos = this.videos.concat(data)
- if (this.groupByDate) this.buildGroupedDateLabels()
+ if (this.groupByDate) this.buildGroupedDateLabels()
- this.onMoreVideos()
+ this.onMoreVideos()
- this.onDataSubject.next(data)
- },
+ this.onDataSubject.next(data)
+ },
- error => {
- const message = $localize`Cannot load more videos. Try again later.`
+ error: err => {
+ const message = $localize`Cannot load more videos. Try again later.`
- console.error(message, { error })
- this.notifier.error(message)
- }
- )
+ console.error(message, { err })
+ this.notifier.error(message)
+ }
+ })
}
reloadVideos () {
if (res === false) return
this.videoBlocklistService.unblockVideo(this.video.id)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Video ${this.video.name} unblocked.`)
this.video.blacklisted = false
this.videoUnblocked.emit()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
async removeVideo () {
if (res === false) return
this.videoService.removeVideo(this.video.id)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Video ${this.video.name} deleted.`)
this.videoRemoved.emit()
},
- error => this.notifier.error(error.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
duplicateVideo () {
this.redundancyService.addVideoRedundancy(this.video)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
const message = $localize`This video will be duplicated by your instance.`
this.notifier.success(message)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
muteVideoAccount () {
const params = { nameWithHost: Actor.CREATE_BY_STRING(this.video.account.name, this.video.account.host) }
this.blocklistService.blockAccountByUser(params)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Account ${params.nameWithHost} muted.`)
this.videoAccountMuted.emit()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
onVideoBlocked () {
import { mapValues, pick } from 'lodash-es'
+import { firstValueFrom } from 'rxjs'
import { tap } from 'rxjs/operators'
import { Component, ElementRef, Inject, LOCALE_ID, ViewChild } from '@angular/core'
import { AuthService, HooksService, Notifier } from '@app/core'
const observable = this.videoService.getVideoFileMetadata(file.metadataUrl)
.pipe(tap(res => file.metadata = res))
- return observable.toPromise()
+ return firstValueFrom(observable)
}
}
addToWatchLater () {
const body = { videoId: this.video.id }
- this.videoPlaylistService.addVideoInPlaylist(this.watchLaterPlaylist.id, body).subscribe(
- res => {
- this.watchLaterPlaylist.playlistElementId = res.videoPlaylistElement.id
- }
- )
+ this.videoPlaylistService.addVideoInPlaylist(this.watchLaterPlaylist.id, body)
+ .subscribe(
+ res => {
+ this.watchLaterPlaylist.playlistElementId = res.videoPlaylistElement.id
+ }
+ )
}
removeFromWatchLater () {
privacy: VideoPlaylistPrivacy.PRIVATE
}
- this.videoPlaylistService.createVideoPlaylist(videoPlaylistCreate).subscribe(
- () => {
- this.isNewPlaylistBlockOpened = false
+ this.videoPlaylistService.createVideoPlaylist(videoPlaylistCreate)
+ .subscribe({
+ next: () => {
+ this.isNewPlaylistBlockOpened = false
- this.cd.markForCheck()
- },
+ this.cd.markForCheck()
+ },
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
onVideoPlaylistSearchChanged () {
}
this.videoPlaylistService.updateVideoOfPlaylist(playlist.id, element.playlistElementId, body, this.video.id)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Timestamps updated`)
},
- err => {
- this.notifier.error(err.message)
- },
+ error: err => this.notifier.error(err.message),
- () => this.cd.markForCheck()
- )
+ complete: () => this.cd.markForCheck()
+ })
}
private isOptionalRowDisplayed (playlist: PlaylistSummary) {
private removeVideoFromPlaylist (playlist: PlaylistSummary, elementId: number) {
this.videoPlaylistService.removeVideoFromPlaylist(playlist.id, elementId, this.video.id)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Video removed from ${playlist.displayName}`)
},
- err => {
- this.notifier.error(err.message)
- },
+ error: err => this.notifier.error(err.message),
- () => this.cd.markForCheck()
- )
+ complete: () => this.cd.markForCheck()
+ })
}
private listenToVideoPlaylistChange () {
if (element.stopTimestamp && element.stopTimestamp !== this.video.duration) body.stopTimestamp = element.stopTimestamp
this.videoPlaylistService.addVideoInPlaylist(playlist.id, body)
- .subscribe(
- res => {
+ .subscribe({
+ next: res => {
const message = body.startTimestamp || body.stopTimestamp
? $localize`Video added in ${playlist.displayName} at timestamps ${this.formatTimestamp(element)}`
: $localize`Video added in ${playlist.displayName}`
if (element) element.playlistElementId = res.videoPlaylistElement.id
},
- err => {
- this.notifier.error(err.message)
- },
+ error: err => this.notifier.error(err.message),
- () => this.cd.markForCheck()
- )
+ complete: () => this.cd.markForCheck()
+ })
}
private formatTimestamp (element: PlaylistElement) {
const videoId = this.playlistElement.video ? this.playlistElement.video.id : undefined
this.videoPlaylistService.removeVideoFromPlaylist(this.playlist.id, playlistElement.id, videoId)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Video removed from ${this.playlist.displayName}`)
this.elementRemoved.emit(playlistElement)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
this.moreDropdown.close()
}
body.stopTimestamp = this.timestampOptions.stopTimestampEnabled ? this.timestampOptions.stopTimestamp : null
this.videoPlaylistService.updateVideoOfPlaylist(this.playlist.id, playlistElement.id, body, this.playlistElement.video.id)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`Timestamps updated`)
playlistElement.startTimestamp = body.startTimestamp
this.cdr.detectChanges()
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
this.moreDropdown.close()
}
import * as debug from 'debug'
-import { ReplaySubject } from 'rxjs'
+import { firstValueFrom, ReplaySubject } from 'rxjs'
import { first, shareReplay } from 'rxjs/operators'
import { RegisterClientHelpers } from 'src/types/register-client-option.model'
import { getHookType, internalRunHook } from '@shared/core-utils/plugins/hooks'
ensurePluginsAreLoaded (scope: PluginClientScope) {
this.loadPluginsByScope(scope)
- return this.pluginsLoaded[scope].asObservable()
+ const obs = this.pluginsLoaded[scope].asObservable()
.pipe(first(), shareReplay())
- .toPromise()
+
+ return firstValueFrom(obs)
}
async reloadLoadedScopes () {