/scripts/i18n/generate-iso639-target.ts
# Other
+/dump.rdb
+/.theia/
/profiling/
/*.zip
/*.tar.xz
inputName="autoPlayVideo" formControlName="autoPlayVideo"
i18n-labelText labelText="Automatically plays video"
></my-peertube-checkbox>
+
+ <my-peertube-checkbox
+ inputName="autoPlayNextVideo" formControlName="autoPlayNextVideo"
+ i18n-labelText labelText="Automatically starts playing next video"
+ ></my-peertube-checkbox>
</div>
<input type="submit" i18n-value value="Save" [disabled]="!form.valid">
nsfwPolicy: null,
webTorrentEnabled: null,
autoPlayVideo: null,
+ autoPlayNextVideo: null,
videoLanguages: null
})
nsfwPolicy: this.user.nsfwPolicy,
webTorrentEnabled: this.user.webTorrentEnabled,
autoPlayVideo: this.user.autoPlayVideo === true,
+ autoPlayNextVideo: this.user.autoPlayNextVideo,
videoLanguages
})
})
const nsfwPolicy = this.form.value[ 'nsfwPolicy' ]
const webTorrentEnabled = this.form.value['webTorrentEnabled']
const autoPlayVideo = this.form.value['autoPlayVideo']
+ const autoPlayNextVideo = this.form.value['autoPlayNextVideo']
let videoLanguages: string[] = this.form.value['videoLanguages']
if (Array.isArray(videoLanguages)) {
nsfwPolicy,
webTorrentEnabled,
autoPlayVideo,
+ autoPlayNextVideo,
videoLanguages
}
adminFlags?: UserAdminFlag
autoPlayVideo: boolean
+ autoPlayNextVideo: boolean
webTorrentEnabled: boolean
videosHistoryEnabled: boolean
videoLanguages: string[]
<my-video-comments [video]="video" [user]="user"></my-video-comments>
</div>
- <my-recommended-videos [inputRecommendation]="{ uuid: video.uuid, tags: video.tags }" [user]="user"></my-recommended-videos>
+ <my-recommended-videos
+ [inputRecommendation]="{ uuid: video.uuid, tags: video.tags }"
+ [user]="user"
+ (gotRecommendations)="onRecommendations($event)"
+ ></my-recommended-videos>
</div>
<div class="row privacy-concerns" *ngIf="hasAlreadyAcceptedPrivacyConcern === false">
import { PluginService } from '@app/core/plugins/plugin.service'
import { HooksService } from '@app/core/plugins/hooks.service'
import { PlatformLocation } from '@angular/common'
+import { randomInt } from '@shared/core-utils/miscs/miscs'
@Component({
selector: 'my-video-watch',
remoteServerDown = false
hotkeys: Hotkey[]
+ private nextVideoUuid = ''
private currentTime: number
private paramsSub: Subscription
private queryParamsSub: Subscription
return this.video.tags
}
+ onRecommendations (videos: Video[]) {
+ if (videos.length > 0) {
+ // Pick a random video until the recommendations are improved
+ this.nextVideoUuid = videos[randomInt(0,videos.length - 1)].uuid
+ }
+ }
+
onVideoRemoved () {
this.redirectService.redirectToHomepage()
}
this.player.one('ended', () => {
if (this.playlist) {
this.zone.run(() => this.videoWatchPlaylist.navigateToNextPlaylistVideo())
+ } else if (this.user && this.user.autoPlayNextVideo) {
+ this.zone.run(() => this.autoplayNext())
}
})
this.hooks.runAction('action:video-watch.video.loaded', 'video-watch')
}
+ private autoplayNext () {
+ if (this.nextVideoUuid) {
+ this.router.navigate([ '/videos/watch', this.nextVideoUuid ])
+ }
+ }
+
private setRating (nextRating: UserVideoRateType) {
const ratingMethods: { [id in UserVideoRateType]: (id: number) => Observable<any> } = {
like: this.videoService.setVideoLike,
-import { Component, Input, OnChanges } from '@angular/core'
+import { Component, Input, Output, OnChanges, EventEmitter } from '@angular/core'
import { Observable } from 'rxjs'
import { Video } from '@app/shared/video/video.model'
import { RecommendationInfo } from '@app/shared/video/recommendation-info.model'
export class RecommendedVideosComponent implements OnChanges {
@Input() inputRecommendation: RecommendationInfo
@Input() user: User
+ @Output() gotRecommendations = new EventEmitter<Video[]>()
readonly hasVideos$: Observable<boolean>
readonly videos$: Observable<Video[]>
) {
this.videos$ = this.store.recommendations$
this.hasVideos$ = this.store.hasRecommendations$
+ this.videos$.subscribe(videos => this.gotRecommendations.emit(videos))
}
public ngOnChanges (): void {
if (body.nsfwPolicy !== undefined) user.nsfwPolicy = body.nsfwPolicy
if (body.webTorrentEnabled !== undefined) user.webTorrentEnabled = body.webTorrentEnabled
if (body.autoPlayVideo !== undefined) user.autoPlayVideo = body.autoPlayVideo
+ if (body.autoPlayNextVideo !== undefined) user.autoPlayNextVideo = body.autoPlayNextVideo
if (body.videosHistoryEnabled !== undefined) user.videosHistoryEnabled = body.videosHistoryEnabled
if (body.videoLanguages !== undefined) user.videoLanguages = body.videoLanguages
if (body.theme !== undefined) user.theme = body.theme
return isBooleanValid(value)
}
+function isUserAutoPlayNextVideoValid (value: any) {
+ return isBooleanValid(value)
+}
+
function isNoInstanceConfigWarningModal (value: any) {
return isBooleanValid(value)
}
isUserNSFWPolicyValid,
isUserWebTorrentEnabledValid,
isUserAutoPlayVideoValid,
+ isUserAutoPlayNextVideoValid,
isUserDisplayNameValid,
isUserDescriptionValid,
isNoInstanceConfigWarningModal,
isNoInstanceConfigWarningModal,
isUserAdminFlagsValid,
isUserAutoPlayVideoValid,
+ isUserAutoPlayNextVideoValid,
isUserBlockedReasonValid,
isUserBlockedValid,
isUserEmailVerifiedValid,
@Column
autoPlayVideo: boolean
+ @AllowNull(false)
+ @Default(false)
+ @Is('UserAutoPlayNextVideo', value => throwIfNotValid(value, isUserAutoPlayNextVideoValid, 'auto play next video boolean'))
+ @Column
+ autoPlayNextVideo: boolean
+
@AllowNull(true)
@Default(null)
@Is('UserVideoLanguages', value => throwIfNotValid(value, isUserVideoLanguages, 'video languages'))
webTorrentEnabled: this.webTorrentEnabled,
videosHistoryEnabled: this.videosHistoryEnabled,
autoPlayVideo: this.autoPlayVideo,
+ autoPlayNextVideo: this.autoPlayNextVideo,
videoLanguages: this.videoLanguages,
role: this.role,
await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
})
+ it('Should fail with an invalid autoPlayNextVideo attribute', async function () {
+ const fields = {
+ autoPlayNextVideo: -1
+ }
+
+ await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
+ })
+
it('Should fail with an invalid videosHistoryEnabled attribute', async function () {
const fields = {
videosHistoryEnabled: -1
expect(user.autoPlayVideo).to.be.false
})
+ it('Should be able to change the autoPlayNextVideo attribute', async function () {
+ await updateMyUser({
+ url: server.url,
+ accessToken: accessTokenUser,
+ autoPlayNextVideo: true
+ })
+
+ const res = await getMyUserInformation(server.url, accessTokenUser)
+ const user = res.body
+
+ expect(user.autoPlayNextVideo).to.be.true
+ })
+
it('Should be able to change the email attribute', async function () {
await updateMyUser({
url: server.url,
webTorrentEnabled?: boolean
autoPlayVideo?: boolean
+ autoPlayNextVideo?: boolean
videosHistoryEnabled?: boolean
videoLanguages?: string[]
adminFlags?: UserAdminFlag
autoPlayVideo: boolean
+ autoPlayNextVideo: boolean
webTorrentEnabled: boolean
videosHistoryEnabled: boolean
videoLanguages: string[]