}
loadMoreChannels () {
- this.videoChannelService.listAccountVideoChannels(this.account, this.channelPagination)
+ const options = {
+ account: this.account,
+ componentPagination: this.channelPagination,
+ sort: '-updatedAt'
+ }
+
+ this.videoChannelService.listAccountVideoChannels(options)
.pipe(
tap(res => this.channelPagination.totalItems = res.total),
switchMap(res => from(res.data)),
distinctUntilChanged(),
switchMap(accountId => this.accountService.getAccount(accountId)),
tap(account => this.onAccount(account)),
- switchMap(account => this.videoChannelService.listAccountVideoChannels(account)),
+ switchMap(account => this.videoChannelService.listAccountVideoChannels({ account })),
catchError(err => this.restExtractor.redirectTo404IfNotFound(err, 'other', [
HttpStatusCode.BAD_REQUEST_400,
HttpStatusCode.NOT_FOUND_404
this.authService.userInformationLoaded
.pipe(mergeMap(() => {
const user = this.authService.getUser()
+ const options = {
+ account: user.account,
+ withStats: true,
+ search: this.search,
+ sort: '-updatedAt'
+ }
- return this.videoChannelService.listAccountVideoChannels(user.account, null, true, this.search)
+ return this.videoChannelService.listAccountVideoChannels(options)
})).subscribe(res => {
this.videoChannels = res.data
this.totalItems = res.total
<div class="modal-body" [formGroup]="form">
<div class="form-group">
<label i18n for="channel">Select a channel to receive the video</label>
- <div class="peertube-select-container">
- <select formControlName="channel" id="channel" class="form-control">
- <option i18n value="undefined" disabled>Channel that will receive the video</option>
- <option *ngFor="let channel of videoChannels" [value]="channel.id">{{ channel.displayName }}
- </option>
- </select>
- </div>
+ <my-select-channel labelForId="channel" formControlName="channel" [items]="videoChannels"></my-select-channel>
+
<div *ngIf="formErrors.channel" class="form-error">{{ formErrors.channel }}</div>
</div>
</div>
-import { switchMap } from 'rxjs/operators'
+import { SelectChannelItem } from 'src/types/select-options-item.model'
import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
import { AuthService, Notifier } from '@app/core'
+import { listUserChannels } from '@app/helpers'
import { OWNERSHIP_CHANGE_CHANNEL_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
-import { VideoChannelService, VideoOwnershipService } from '@app/shared/shared-main'
+import { VideoOwnershipService } from '@app/shared/shared-main'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
-import { VideoChangeOwnership, VideoChannel } from '@shared/models'
+import { VideoChangeOwnership } from '@shared/models'
@Component({
selector: 'my-accept-ownership',
@ViewChild('modal', { static: true }) modal: ElementRef
videoChangeOwnership: VideoChangeOwnership | undefined = undefined
-
- videoChannels: VideoChannel[]
+ videoChannels: SelectChannelItem[]
error: string = null
private videoOwnershipService: VideoOwnershipService,
private notifier: Notifier,
private authService: AuthService,
- private videoChannelService: VideoChannelService,
private modalService: NgbModal
) {
super()
ngOnInit () {
this.videoChannels = []
- this.authService.userInformationLoaded
- .pipe(switchMap(() => this.videoChannelService.listAccountVideoChannels(this.authService.getUser().account)))
- .subscribe(videoChannels => this.videoChannels = videoChannels.data)
+ listUserChannels(this.authService)
+ .subscribe(channels => this.videoChannels = channels)
this.buildForm({
channel: OWNERSHIP_CHANGE_CHANNEL_VALIDATOR
import { map, switchMap } from 'rxjs/operators'
import { Injectable } from '@angular/core'
import { ActivatedRouteSnapshot, Resolve } from '@angular/router'
-import { VideoCaptionService, VideoChannelService, VideoDetails, VideoService } from '@app/shared/shared-main'
+import { AuthService } from '@app/core'
+import { listUserChannels } from '@app/helpers'
+import { VideoCaptionService, VideoDetails, VideoService } from '@app/shared/shared-main'
import { LiveVideoService } from '@app/shared/shared-video-live'
@Injectable()
constructor (
private videoService: VideoService,
private liveVideoService: LiveVideoService,
- private videoChannelService: VideoChannelService,
+ private authService: AuthService,
private videoCaptionService: VideoCaptionService
) {
}
.loadCompleteDescription(video.descriptionPath)
.pipe(map(description => Object.assign(video, { description }))),
- this.videoChannelService
- .listAccountVideoChannels(video.account)
- .pipe(
- map(result => result.data),
- map(videoChannels => videoChannels.map(c => ({
- id: c.id,
- label: c.displayName,
- support: c.support,
- avatarPath: c.avatar?.path
- })))
- ),
+ listUserChannels(this.authService),
this.videoCaptionService
.listCaptions(video.id)
const videoChannels = user.videoChannels
if (Array.isArray(videoChannels) === false) return undefined
- return videoChannels.map(c => ({
- id: c.id,
- label: c.displayName,
- support: c.support,
- avatarPath: c.avatar?.path
- }) as SelectChannelItem)
+ return videoChannels
+ .sort((a, b) => {
+ if (a.updatedAt < b.updatedAt) return 1
+ if (a.updatedAt > b.updatedAt) return -1
+ return 0
+ })
+ .map(c => ({
+ id: c.id,
+ label: c.displayName,
+ support: c.support,
+ avatarPath: c.avatar?.path
+ }) as SelectChannelItem)
}))
}
export class Account extends Actor implements ServerAccount {
displayName: string
description: string
+
+ updatedAt: Date | string
+
nameWithHost: string
nameWithHostForced: string
+
mutedByUser: boolean
mutedByInstance: boolean
mutedServerByUser: boolean
this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host)
this.nameWithHostForced = Actor.CREATE_BY_STRING(this.name, this.host, true)
+ if (hash.updatedAt) this.updatedAt = new Date(hash.updatedAt.toString())
+
this.mutedByUser = false
this.mutedByInstance = false
this.mutedServerByUser = false
followersCount: number
createdAt: Date | string
- updatedAt: Date | string
avatar: ActorImage
this.followersCount = hash.followersCount
if (hash.createdAt) this.createdAt = new Date(hash.createdAt.toString())
- if (hash.updatedAt) this.updatedAt = new Date(hash.updatedAt.toString())
this.avatar = hash.avatar
this.isLocal = Actor.IS_LOCAL(this.host)
banner: ActorImage
bannerUrl: string
+ updatedAt: Date | string
+
ownerAccount?: ServerAccount
ownerBy?: string
this.videosCount = hash.videosCount
+ if (hash.updatedAt) this.updatedAt = new Date(hash.updatedAt.toString())
+
if (hash.viewsPerDay) {
this.viewsPerDay = hash.viewsPerDay.map(v => ({ ...v, date: new Date(v.date) }))
}
)
}
- listAccountVideoChannels (
- account: Account,
- componentPagination?: ComponentPaginationLight,
- withStats = false,
+ listAccountVideoChannels (options: {
+ account: Account
+ componentPagination?: ComponentPaginationLight
+ withStats?: boolean
+ sort?: string
search?: string
- ): Observable<ResultList<VideoChannel>> {
+ }): Observable<ResultList<VideoChannel>> {
+ const { account, componentPagination, withStats = false, sort, search } = options
+
const pagination = componentPagination
? this.restService.componentPaginationToRestPagination(componentPagination)
: { start: 0, count: 20 }
let params = new HttpParams()
- params = this.restService.addRestGetParams(params, pagination)
+ params = this.restService.addRestGetParams(params, pagination, sort)
params = params.set('withStats', withStats + '')
- if (search) {
- params = params.set('search', search)
- }
+ if (search) params = params.set('search', search)
const url = AccountService.BASE_ACCOUNT_URL + account.nameWithHost + '/video-channels'
return this.authHttp.get<ResultList<VideoChannelServer>>(url, { params })