mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 09:49:20 +02:00

* Add Scheduled Lives functionality through originallyPublishedAt Implements #6604 by reusing the originallyPublishedAt field of isLive videos to mark "waiting for live" videos as scheduled at a set time. * Hide scheduled lives from Browse Videos page * Add tests for Scheduled Live videos * Make scheduled lives use a dedicated scheduledAt field in the VideoLive table * Plan live schedules to evolve in the future * Use a dedicated table to store live schedules, so we can add multiple schedules in the future and also add a title, description etc. for a specific schedule * Adapt REST API to use an array to store/get live schedules * Add REST API param so it's the client choice to include or not scheduled lives * Export schedules info in user import/export --------- Co-authored-by: Chocobozzz <me@florianbigard.com>
79 lines
2.4 KiB
TypeScript
79 lines
2.4 KiB
TypeScript
import { NgIf } from '@angular/common'
|
|
import { Component, inject, OnDestroy, OnInit, viewChild } from '@angular/core'
|
|
import { ComponentPaginationLight, DisableForReuseHook, ScreenService } from '@app/core'
|
|
import { Account } from '@app/shared/shared-main/account/account.model'
|
|
import { AccountService } from '@app/shared/shared-main/account/account.service'
|
|
import { VideoService } from '@app/shared/shared-main/video/video.service'
|
|
import { VideoFilters } from '@app/shared/shared-video-miniature/video-filters.model'
|
|
import { VideoSortField } from '@peertube/peertube-models'
|
|
import { Subscription } from 'rxjs'
|
|
import { VideosListComponent } from '../../shared/shared-video-miniature/videos-list.component'
|
|
|
|
@Component({
|
|
selector: 'my-account-videos',
|
|
templateUrl: './account-videos.component.html',
|
|
imports: [ NgIf, VideosListComponent ]
|
|
})
|
|
export class AccountVideosComponent implements OnInit, OnDestroy, DisableForReuseHook {
|
|
private screenService = inject(ScreenService)
|
|
private accountService = inject(AccountService)
|
|
private videoService = inject(VideoService)
|
|
|
|
readonly videosList = viewChild<VideosListComponent>('videosList')
|
|
|
|
getVideosObservableFunction = this.getVideosObservable.bind(this)
|
|
getSyndicationItemsFunction = this.getSyndicationItems.bind(this)
|
|
|
|
defaultSort = '-publishedAt' as VideoSortField
|
|
|
|
account: Account
|
|
disabled = false
|
|
|
|
private alreadyLoaded = false
|
|
|
|
private accountSub: Subscription
|
|
|
|
ngOnInit () {
|
|
// Parent get the account for us
|
|
this.accountSub = this.accountService.accountLoaded
|
|
.subscribe(account => {
|
|
if (account.id === this.account?.id) return
|
|
|
|
this.account = account
|
|
if (this.alreadyLoaded) this.videosList().reloadVideos()
|
|
|
|
this.alreadyLoaded = true
|
|
})
|
|
}
|
|
|
|
ngOnDestroy () {
|
|
if (this.accountSub) this.accountSub.unsubscribe()
|
|
}
|
|
|
|
getVideosObservable (pagination: ComponentPaginationLight, filters: VideoFilters) {
|
|
return this.videoService.listAccountVideos({
|
|
...filters.toVideosAPIObject(),
|
|
|
|
videoPagination: pagination,
|
|
account: this.account,
|
|
skipCount: true,
|
|
includeScheduledLive: true
|
|
})
|
|
}
|
|
|
|
getSyndicationItems () {
|
|
return this.videoService.getAccountFeedUrls(this.account.id)
|
|
}
|
|
|
|
displayAsRow () {
|
|
return this.screenService.isInMobileView()
|
|
}
|
|
|
|
disableForReuse () {
|
|
this.disabled = true
|
|
}
|
|
|
|
enabledForReuse () {
|
|
this.disabled = false
|
|
}
|
|
}
|