<my-video-miniature
*ngFor="let video of getVideosOf(videoChannel)"
- [video]="video" [user]="user" [displayVideoActions]="true"
+ [video]="video" [user]="userMiniature" [displayVideoActions]="true"
></my-video-miniature>
</div>
+import { from, Subject, Subscription } from 'rxjs'
+import { concatMap, map, switchMap, tap } from 'rxjs/operators'
import { Component, OnDestroy, OnInit } from '@angular/core'
-import { ActivatedRoute } from '@angular/router'
+import { UserService } from '@app/shared'
import { Account } from '@app/shared/account/account.model'
import { AccountService } from '@app/shared/account/account.service'
-import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
-import { concatMap, map, switchMap, tap } from 'rxjs/operators'
-import { from, Subject, Subscription } from 'rxjs'
+import { ScreenService } from '@app/shared/misc/screen.service'
+import { ComponentPagination, hasMoreItems } from '@app/shared/rest/component-pagination.model'
import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
+import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
+import { VideoSortField } from '@app/shared/video/sort-field.type'
import { Video } from '@app/shared/video/video.model'
-import { AuthService } from '@app/core'
import { VideoService } from '@app/shared/video/video.service'
-import { VideoSortField } from '@app/shared/video/sort-field.type'
-import { ComponentPagination, hasMoreItems } from '@app/shared/rest/component-pagination.model'
-import { ScreenService } from '@app/shared/misc/screen.service'
+import { User } from '@shared/models'
@Component({
selector: 'my-account-video-channels',
onChannelDataSubject = new Subject<any>()
+ userMiniature: User
+
private accountSub: Subscription
constructor (
- private route: ActivatedRoute,
- private authService: AuthService,
private accountService: AccountService,
private videoChannelService: VideoChannelService,
private videoService: VideoService,
- private screenService: ScreenService
+ private screenService: ScreenService,
+ private userService: UserService
) { }
- get user () {
- return this.authService.getUser()
- }
-
ngOnInit () {
// Parent get the account for us
this.accountSub = this.accountService.accountLoaded
this.loadMoreChannels()
})
+
+ this.userService.getAnonymousOrLoggedUser()
+ .subscribe(user => this.userMiniature = user)
}
ngOnDestroy () {
<div class="video" *ngFor="let video of videos">
<my-video-miniature
[video]="video" [displayAsRow]="true"
- (videoRemoved)="removeVideoFromArray(video)" (videoBlocked)="removeVideoFromArray(video)"></my-video-miniature>
+ (videoRemoved)="removeVideoFromArray(video)" (videoBlocked)="removeVideoFromArray(video)"
+ ></my-video-miniature>
</div>
</div>
const newPagination = immutableAssign(this.pagination, { currentPage: page })
return this.videoService
- .getVideoChannelVideos(this.videoChannel, newPagination, this.sort)
+ .getVideoChannelVideos(this.videoChannel, newPagination, this.sort, this.nsfwPolicy)
.pipe(
tap(({ total }) => {
this.titlePage = this.i18n(`{total, plural, =1 {Published 1 video} other {Published {{total}} videos}}`, { total })
const scrollEvent = eventsObs.pipe(filter((e: Event): e is Scroll => e instanceof Scroll))
scrollEvent.subscribe(e => {
- console.log(e)
if (e.position) {
return this.viewportScroller.scrollToPosition(e.position)
}
<h4 i18n class="modal-title">Settings</h4>
<my-global-icon iconName="cross" aria-label="Close" role="button" (click)="hide()"></my-global-icon>
</div>
-
+
<div class="modal-body">
<div i18n class="mb-4 quick-settings-title">Display settings</div>
- <my-account-video-settings *ngIf="!isUserLoggedIn()" [user]="user" [userInformationLoaded]="userInformationLoaded" [reactiveUpdate]="true" [notifyOnUpdate]="true">
+ <my-account-video-settings
+ *ngIf="!isUserLoggedIn()"
+ [user]="user" [userInformationLoaded]="userInformationLoaded" [reactiveUpdate]="true" [notifyOnUpdate]="true"
+ >
+
<ng-container ngProjectAs="inner-title">
<div i18n class="mb-4 mt-4 quick-settings-title">Video settings</div>
</ng-container>
<div i18n class="mb-4 mt-4 quick-settings-title">Interface settings</div>
- <my-account-interface-settings *ngIf="!isUserLoggedIn()" [user]="user" [userInformationLoaded]="userInformationLoaded" [reactiveUpdate]="true" [notifyOnUpdate]="true"></my-account-interface-settings>
+ <my-account-interface-settings
+ *ngIf="!isUserLoggedIn()"
+ [user]="user" [userInformationLoaded]="userInformationLoaded" [reactiveUpdate]="true" [notifyOnUpdate]="true"
+ ></my-account-interface-settings>
</div>
</ng-template>
ngOnInit () {
this.user = this.userService.getAnonymousUser()
- this.localStorageService.watch().subscribe(
- () => this.user = this.userService.getAnonymousUser()
- )
+ this.localStorageService.watch()
+ .subscribe(
+ () => this.user = this.userService.getAnonymousUser()
+ )
+
this.userInformationLoaded.next(true)
this.authService.loginChangedSource
<div *ngIf="isVideo(result)" class="entry video">
<my-video-miniature
- [video]="result" [user]="user" [displayAsRow]="true" [displayVideoActions]="!hideActions()"
+ [video]="result" [user]="userMiniature" [displayAsRow]="true" [displayVideoActions]="!hideActions()"
[displayOptions]="videoDisplayOptions" [useLazyLoadUrl]="advancedSearch.searchTarget === 'search-index'"
(videoBlocked)="removeVideoFromArray(result)" (videoRemoved)="removeVideoFromArray(result)"
></my-video-miniature>
import { HooksService } from '@app/core/plugins/hooks.service'
import { AdvancedSearch } from '@app/search/advanced-search.model'
import { SearchService } from '@app/search/search.service'
+import { UserService } from '@app/shared'
import { immutableAssign } from '@app/shared/misc/utils'
import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
import { Video } from '@app/shared/video/video.model'
import { MetaService } from '@ngx-meta/core'
import { I18n } from '@ngx-translate/i18n-polyfill'
-import { ServerConfig } from '@shared/models'
+import { ServerConfig, User } from '@shared/models'
import { SearchTargetType } from '@shared/models/search/search-target-query.model'
@Component({
errorMessage: string
serverConfig: ServerConfig
+ userMiniature: User
+
private subActivatedRoute: Subscription
private isInitialLoad = false // set to false to show the search filters on first arrival
private firstSearch = true
private notifier: Notifier,
private searchService: SearchService,
private authService: AuthService,
+ private userService: UserService,
private hooks: HooksService,
private serverService: ServerService
) { }
- get user () {
- return this.authService.getUser()
- }
-
ngOnInit () {
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
err => this.notifier.error(err.text)
)
+ this.userService.getAnonymousOrLoggedUser()
+ .subscribe(user => this.userMiniature = user)
+
this.hooks.runAction('action:search.init', 'search')
}
-import { from, Observable } from 'rxjs'
-import { catchError, concatMap, map, shareReplay, toArray } from 'rxjs/operators'
+import { has } from 'lodash-es'
+import { BytesPipe } from 'ngx-pipes'
+import { SortMeta } from 'primeng/api'
+import { from, Observable, of } from 'rxjs'
+import { catchError, concatMap, first, map, shareReplay, toArray, throttleTime, filter } from 'rxjs/operators'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable } from '@angular/core'
-import { ResultList, User as UserServerModel, UserCreate, UserRole, UserUpdate, UserUpdateMe, UserVideoQuota } from '../../../../../shared'
-import { environment } from '../../../environments/environment'
-import { RestExtractor, RestPagination, RestService } from '../rest'
-import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
-import { SortMeta } from 'primeng/api'
-import { BytesPipe } from 'ngx-pipes'
+import { AuthService } from '@app/core/auth'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { UserRegister } from '@shared/models/users/user-register.model'
-import { User } from './user.model'
import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type'
-import { has } from 'lodash-es'
+import { ResultList, User as UserServerModel, UserCreate, UserRole, UserUpdate, UserUpdateMe, UserVideoQuota } from '../../../../../shared'
+import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
+import { environment } from '../../../environments/environment'
import { LocalStorageService, SessionStorageService } from '../misc/storage.service'
+import { RestExtractor, RestPagination, RestService } from '../rest'
+import { User } from './user.model'
@Injectable()
export class UserService {
constructor (
private authHttp: HttpClient,
+ private authService: AuthService,
private restExtractor: RestExtractor,
private restService: RestService,
private localStorageService: LocalStorageService,
}
}
+ listenAnonymousUpdate () {
+ return this.localStorageService.watch([
+ User.KEYS.NSFW_POLICY,
+ User.KEYS.WEBTORRENT_ENABLED,
+ User.KEYS.AUTO_PLAY_VIDEO,
+ User.KEYS.AUTO_PLAY_VIDEO_PLAYLIST,
+ User.KEYS.THEME,
+ User.KEYS.VIDEO_LANGUAGES
+ ]).pipe(
+ throttleTime(200),
+ filter(() => this.authService.isLoggedIn() !== true),
+ map(() => this.getAnonymousUser())
+ )
+ }
+
deleteMe () {
const url = UserService.BASE_USERS_URL + 'me'
}
getAnonymousUser () {
- let videoLanguages
+ let videoLanguages: string[]
try {
videoLanguages = JSON.parse(this.localStorageService.getItem(User.KEYS.VIDEO_LANGUAGES))
)
}
+ getAnonymousOrLoggedUser () {
+ if (!this.authService.isLoggedIn()) {
+ return of(this.getAnonymousUser())
+ }
+
+ return this.authService.userInformationLoaded
+ .pipe(
+ first(),
+ map(() => this.authService.getUser())
+ )
+ }
+
private formatUser (user: UserServerModel) {
let videoQuota
if (user.videoQuota === -1) {
<div class="video-wrapper">
<my-video-miniature
[fitWidth]="true"
- [video]="video" [user]="user" [ownerDisplayType]="ownerDisplayType"
+ [video]="video" [user]="userMiniature" [ownerDisplayType]="ownerDisplayType"
[displayVideoActions]="displayVideoActions" [displayOptions]="displayOptions"
(videoBlocked)="removeVideoFromArray(video)" (videoRemoved)="removeVideoFromArray(video)"
>
-import { debounceTime, first, tap, throttleTime } from 'rxjs/operators'
+import { fromEvent, Observable, of, Subject, Subscription } from 'rxjs'
+import { debounceTime, tap, throttleTime, switchMap } from 'rxjs/operators'
import { OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
-import { fromEvent, Observable, of, Subject, Subscription } from 'rxjs'
-import { AuthService } from '../../core/auth'
-import { ComponentPaginationLight } from '../rest/component-pagination.model'
-import { VideoSortField } from './sort-field.type'
-import { Video } from './video.model'
-import { ScreenService } from '@app/shared/misc/screen.service'
-import { MiniatureDisplayOptions, OwnerDisplayType } from '@app/shared/video/video-miniature.component'
-import { Syndication } from '@app/shared/video/syndication.model'
import { Notifier, ServerService } from '@app/core'
import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook'
+import { GlobalIconName } from '@app/shared/images/global-icon.component'
+import { ScreenService } from '@app/shared/misc/screen.service'
+import { Syndication } from '@app/shared/video/syndication.model'
+import { MiniatureDisplayOptions, OwnerDisplayType } from '@app/shared/video/video-miniature.component'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { isLastMonth, isLastWeek, isToday, isYesterday } from '@shared/core-utils/miscs/date'
import { ServerConfig } from '@shared/models'
-import { GlobalIconName } from '@app/shared/images/global-icon.component'
-import { UserService, User } from '../users'
+import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type'
+import { AuthService } from '../../core/auth'
import { LocalStorageService } from '../misc/storage.service'
+import { ComponentPaginationLight } from '../rest/component-pagination.model'
+import { User, UserService } from '../users'
+import { VideoSortField } from './sort-field.type'
+import { Video } from './video.model'
enum GroupDate {
UNKNOWN = 0,
}
sort: VideoSortField = '-publishedAt'
- categoryOneOf?: number
+ categoryOneOf?: number[]
languageOneOf?: string[]
+ nsfwPolicy?: NSFWPolicyType
defaultSort: VideoSortField = '-publishedAt'
syndicationItems: Syndication[] = []
loadOnInit = true
- useUserVideoLanguagePreferences = false
+ useUserVideoPreferences = false
ownerDisplayType: OwnerDisplayType = 'account'
displayModerationBlock = false
titleTooltip: string
onDataSubject = new Subject<any[]>()
+ userMiniature: User
+
protected serverConfig: ServerConfig
protected abstract notifier: Notifier
abstract generateSyndicationList (): void
- get user () {
- return this.authService.getUser()
- }
-
ngOnInit () {
this.serverConfig = this.serverService.getTmpConfig()
this.serverService.getConfig()
this.calcPageSizes()
- const loadUserObservable = this.loadUserVideoLanguagesIfNeeded()
+ const loadUserObservable = this.loadUserAndSettings()
if (this.loadOnInit === true) {
loadUserObservable.subscribe(() => this.loadMoreVideos())
}
- this.storageService.watch([
- User.KEYS.NSFW_POLICY,
- User.KEYS.VIDEO_LANGUAGES
- ]).pipe(throttleTime(200)).subscribe(
- () => {
- this.loadUserVideoLanguagesIfNeeded()
+ this.userService.listenAnonymousUpdate()
+ .pipe(switchMap(() => this.loadUserAndSettings()))
+ .subscribe(() => {
if (this.hasDoneFirstQuery) this.reloadVideos()
- }
- )
+ })
// Display avatar in mobile view
if (this.screenService.isInMobileView()) {
this.router.navigate([ path ], { queryParams, replaceUrl: true, queryParamsHandling: 'merge' })
}
- private loadUserVideoLanguagesIfNeeded () {
- if (!this.useUserVideoLanguagePreferences) {
- return of(true)
- }
+ private loadUserAndSettings () {
+ return this.userService.getAnonymousOrLoggedUser()
+ .pipe(tap(user => {
+ this.userMiniature = user
- if (!this.authService.isLoggedIn()) {
- this.languageOneOf = this.userService.getAnonymousUser().videoLanguages
- return of(true)
- }
+ if (!this.useUserVideoPreferences) return
- return this.authService.userInformationLoaded
- .pipe(
- first(),
- tap(() => this.languageOneOf = this.user.videoLanguages)
- )
+ this.languageOneOf = user.videoLanguages
+ this.nsfwPolicy = user.nsfwPolicy
+ }))
}
}
videoPagination: ComponentPaginationLight,
sort: VideoSortField,
filter?: VideoFilter,
- categoryOneOf?: number,
+ categoryOneOf?: number[],
languageOneOf?: string[]
+ nsfwPolicy: NSFWPolicyType
}): Observable<ResultList<Video>>
}
getVideoChannelVideos (
videoChannel: VideoChannel,
videoPagination: ComponentPaginationLight,
- sort: VideoSortField
+ sort: VideoSortField,
+ nsfwPolicy?: NSFWPolicyType
): Observable<ResultList<Video>> {
const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
+ if (nsfwPolicy) {
+ params = params.set('nsfw', this.nsfwPolicyToParam(nsfwPolicy))
+ }
+
return this.authHttp
.get<ResultList<Video>>(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.nameWithHost + '/videos', { params })
.pipe(
videoPagination: ComponentPaginationLight,
sort: VideoSortField,
filter?: VideoFilter,
- categoryOneOf?: number,
+ categoryOneOf?: number[],
languageOneOf?: string[],
skipCount?: boolean,
- nsfw?: boolean
+ nsfwPolicy?: NSFWPolicyType
}): Observable<ResultList<Video>> {
- const { videoPagination, sort, filter, categoryOneOf, languageOneOf, skipCount, nsfw } = parameters
+ const { videoPagination, sort, filter, categoryOneOf, languageOneOf, skipCount, nsfwPolicy } = parameters
const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
params = this.restService.addRestGetParams(params, pagination, sort)
if (filter) params = params.set('filter', filter)
- if (categoryOneOf) params = params.set('categoryOneOf', categoryOneOf + '')
if (skipCount) params = params.set('skipCount', skipCount + '')
- if (nsfw) {
- params = params.set('nsfw', nsfw + '')
- } else {
- const nsfwPolicy = this.authService.isLoggedIn()
- ? this.authService.getUser().nsfwPolicy
- : this.userService.getAnonymousUser().nsfwPolicy
- if (this.nsfwPolicyToFilter(nsfwPolicy)) params.set('nsfw', 'false')
+ if (nsfwPolicy) {
+ params = params.set('nsfw', this.nsfwPolicyToParam(nsfwPolicy))
}
if (languageOneOf) {
}
}
+ if (categoryOneOf) {
+ for (const c of categoryOneOf) {
+ params = params.append('categoryOneOf[]', c + '')
+ }
+ }
+
return this.authHttp
.get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params })
.pipe(
return feeds
}
- getVideoFeedUrls (sort: VideoSortField, filter?: VideoFilter, categoryOneOf?: number) {
+ getVideoFeedUrls (sort: VideoSortField, filter?: VideoFilter, categoryOneOf?: number[]) {
let params = this.restService.addRestGetParams(new HttpParams(), undefined, sort)
if (filter) params = params.set('filter', filter)
- if (categoryOneOf) params = params.set('categoryOneOf', categoryOneOf + '')
+ if (categoryOneOf) {
+ for (const c of categoryOneOf) {
+ params = params.append('categoryOneOf[]', c + '')
+ }
+ }
return this.buildBaseFeedUrls(params)
}
return base.filter(o => !!privacies.find(p => p.id === o.id))
}
+ nsfwPolicyToParam (nsfwPolicy: NSFWPolicyType) {
+ return nsfwPolicy === 'do_not_list'
+ ? 'false'
+ : 'both'
+ }
+
private setVideoRate (id: number, rateType: UserVideoRateType) {
const url = VideoService.BASE_VIDEO_URL + id + '/rate'
const body: UserVideoRateUpdate = {
catchError(err => this.restExtractor.handleError(err))
)
}
-
- private nsfwPolicyToFilter (policy: NSFWPolicyType) {
- return policy === 'do_not_list'
- }
}
</div>
<my-recommended-videos
- [inputRecommendation]="{ uuid: video.uuid, tags: video.tags }"
- [user]="user"
- [playlist]="playlist"
- (gotRecommendations)="onRecommendations($event)"
+ [inputRecommendation]="{ uuid: video.uuid, tags: video.tags }"
+ [user]="user"
+ [playlist]="playlist"
+ (gotRecommendations)="onRecommendations($event)"
></my-recommended-videos>
</div>
-import { Injectable, OnInit } from '@angular/core'
-import { RecommendationService } from '@app/videos/recommendations/recommendations.service'
-import { Video } from '@app/shared/video/video.model'
-import { RecommendationInfo } from '@app/shared/video/recommendation-info.model'
-import { VideoService } from '@app/shared/video/video.service'
-import { map, switchMap } from 'rxjs/operators'
import { Observable, of } from 'rxjs'
-import { SearchService } from '@app/search/search.service'
-import { AdvancedSearch } from '@app/search/advanced-search.model'
+import { map, switchMap } from 'rxjs/operators'
+import { Injectable } from '@angular/core'
import { ServerService } from '@app/core'
+import { AdvancedSearch } from '@app/search/advanced-search.model'
+import { SearchService } from '@app/search/search.service'
+import { UserService } from '@app/shared'
+import { RecommendationInfo } from '@app/shared/video/recommendation-info.model'
+import { Video } from '@app/shared/video/video.model'
+import { VideoService } from '@app/shared/video/video.service'
+import { RecommendationService } from '@app/videos/recommendations/recommendations.service'
import { ServerConfig } from '@shared/models'
-import { truncate } from 'lodash'
/**
* Provides "recommendations" by providing the most recently uploaded videos.
constructor (
private videos: VideoService,
private searchService: SearchService,
+ private userService: UserService,
private serverService: ServerService
) {
this.config = this.serverService.getTmpConfig()
this.serverService.getConfig()
.subscribe(config => this.config = config)
- }
+ }
getRecommendations (recommendation: RecommendationInfo): Observable<Video[]> {
return this.fetchPage(1, recommendation)
return defaultSubscription
}
- const params = {
- search: '',
- componentPagination: pagination,
- advancedSearch: new AdvancedSearch({ tagsOneOf: recommendation.tags.join(','), sort: '-createdAt', searchTarget: 'local' })
- }
-
- return this.searchService.searchVideos(params)
- .pipe(
- map(v => v.data),
- switchMap(videos => {
- if (videos.length <= 1) return defaultSubscription
+ return this.userService.getAnonymousOrLoggedUser()
+ .pipe(
+ map(user => {
+ return {
+ search: '',
+ componentPagination: pagination,
+ advancedSearch: new AdvancedSearch({
+ tagsOneOf: recommendation.tags.join(','),
+ sort: '-createdAt',
+ searchTarget: 'local',
+ nsfw: user.nsfwPolicy
+ ? this.videos.nsfwPolicyToParam(user.nsfwPolicy)
+ : undefined
+ })
+ }
+ }),
+ switchMap(params => this.searchService.searchVideos(params)),
+ map(v => v.data),
+ switchMap(videos => {
+ if (videos.length <= 1) return defaultSubscription
- return of(videos)
- })
- )
+ return of(videos)
+ })
+ )
}
}
</div>
<ng-container *ngFor="let video of (videos$ | async); let i = index; let length = count">
- <my-video-miniature
- [displayOptions]="displayOptions" [video]="video" [user]="user"
+ <my-video-miniature
+ [displayOptions]="displayOptions" [video]="video" [user]="userMiniature"
(videoBlocked)="onVideoRemoved()" (videoRemoved)="onVideoRemoved()">
</my-video-miniature>
-
+
<hr *ngIf="!playlist && i == 0 && length > 1" />
</ng-container>
</ng-container>
-import { Component, Input, Output, OnChanges, EventEmitter } from '@angular/core'
import { Observable } from 'rxjs'
-import { Video } from '@app/shared/video/video.model'
+import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core'
+import { AuthService, Notifier } from '@app/core'
+import { User } from '@app/shared'
+import { SessionStorageService } from '@app/shared/misc/storage.service'
+import { UserService } from '@app/shared/users/user.service'
import { VideoPlaylist } from '@app/shared/video-playlist/video-playlist.model'
import { RecommendationInfo } from '@app/shared/video/recommendation-info.model'
+import { MiniatureDisplayOptions } from '@app/shared/video/video-miniature.component'
+import { Video } from '@app/shared/video/video.model'
import { RecommendedVideosStore } from '@app/videos/recommendations/recommended-videos.store'
-import { User } from '@app/shared'
-import { AuthService, Notifier } from '@app/core'
-import { UserService } from '@app/shared/users/user.service'
import { I18n } from '@ngx-translate/i18n-polyfill'
-import { SessionStorageService } from '@app/shared/misc/storage.service'
-import { MiniatureDisplayOptions } from '@app/shared/video/video-miniature.component'
@Component({
selector: 'my-recommended-videos',
templateUrl: './recommended-videos.component.html',
styleUrls: [ './recommended-videos.component.scss' ]
})
-export class RecommendedVideosComponent implements OnChanges {
+export class RecommendedVideosComponent implements OnInit, OnChanges {
@Input() inputRecommendation: RecommendationInfo
- @Input() user: User
@Input() playlist: VideoPlaylist
@Output() gotRecommendations = new EventEmitter<Video[]>()
avatar: true
}
+ userMiniature: User
+
readonly hasVideos$: Observable<boolean>
readonly videos$: Observable<Video[]>
this.autoPlayNextVideoTooltip = this.i18n('When active, the next video is automatically played after the current one.')
}
- public ngOnChanges (): void {
+ ngOnInit () {
+ this.userService.getAnonymousOrLoggedUser()
+ .subscribe(user => this.userMiniature = user)
+ }
+
+ ngOnChanges () {
if (this.inputRecommendation) {
this.store.requestNewRecommendations(this.inputRecommendation)
}
sort = '-publishedAt' as VideoSortField
filter: VideoFilter = 'local'
- useUserVideoLanguagePreferences = true
+ useUserVideoPreferences = true
constructor (
protected i18n: I18n,
filter: this.filter,
categoryOneOf: this.categoryOneOf,
languageOneOf: this.languageOneOf,
+ nsfwPolicy: this.nsfwPolicy,
skipCount: true
}
titlePage: string
defaultSort: VideoSortField = '-likes'
- useUserVideoLanguagePreferences = true
+ useUserVideoPreferences = true
constructor (
protected i18n: I18n,
sort: this.sort,
categoryOneOf: this.categoryOneOf,
languageOneOf: this.languageOneOf,
+ nsfwPolicy: this.nsfwPolicy,
skipCount: true
}
</h1>
<div class="video-wrapper" *ngFor="let video of buildVideos(object.videos)">
- <my-video-miniature [video]="video" [fitWidth]="true" [user]="user" [displayVideoActions]="false">
+ <my-video-miniature [video]="video" [fitWidth]="true" [user]="userMiniature" [displayVideoActions]="false">
</my-video-miniature>
</div>
</div>
</h2>
<div class="video-wrapper" *ngFor="let video of buildVideos(object.videos)">
- <my-video-miniature [video]="video" [fitWidth]="true" [user]="user" [displayVideoActions]="false">
+ <my-video-miniature [video]="video" [fitWidth]="true" [user]="userMiniature" [displayVideoActions]="false">
</my-video-miniature>
</div>
</div>
</div>
<div class="video-wrapper" *ngFor="let video of buildVideos(object.videos)">
- <my-video-miniature [video]="video" [fitWidth]="true" [user]="user" [displayVideoActions]="false">
+ <my-video-miniature [video]="video" [fitWidth]="true" [user]="userMiniature" [displayVideoActions]="false">
</my-video-miniature>
</div>
</div>
+import { Subject } from 'rxjs'
import { Component, OnInit } from '@angular/core'
-import { AuthService, Notifier } from '@app/core'
-import { I18n } from '@ngx-translate/i18n-polyfill'
-import { VideosOverview } from '@app/shared/overview/videos-overview.model'
+import { Notifier } from '@app/core'
+import { User, UserService } from '@app/shared'
+import { ScreenService } from '@app/shared/misc/screen.service'
import { OverviewService } from '@app/shared/overview'
+import { VideosOverview } from '@app/shared/overview/videos-overview.model'
import { Video } from '@app/shared/video/video.model'
-import { ScreenService } from '@app/shared/misc/screen.service'
-import { Subject } from 'rxjs'
@Component({
selector: 'my-video-overview',
overviews: VideosOverview[] = []
notResults = false
+ userMiniature: User
+
private loaded = false
private currentPage = 1
private maxPage = 20
private isLoading = false
constructor (
- private i18n: I18n,
private notifier: Notifier,
- private authService: AuthService,
+ private userService: UserService,
private overviewService: OverviewService,
private screenService: ScreenService
) { }
- get user () {
- return this.authService.getUser()
- }
-
ngOnInit () {
this.loadMoreResults()
+
+ this.userService.getAnonymousOrLoggedUser()
+ .subscribe(user => this.userMiniature = user)
+
+ this.userService.listenAnonymousUpdate()
+ .subscribe(user => this.userMiniature = user)
}
buildVideoChannelBy (object: { videos: Video[] }) {
sort: VideoSortField = '-publishedAt'
groupByDate = true
- useUserVideoLanguagePreferences = true
+ useUserVideoPreferences = true
constructor (
protected i18n: I18n,
sort: this.sort,
categoryOneOf: this.categoryOneOf,
languageOneOf: this.languageOneOf,
+ nsfwPolicy: this.nsfwPolicy,
skipCount: true
}
titlePage: string
defaultSort: VideoSortField = '-trending'
- useUserVideoLanguagePreferences = true
+ useUserVideoPreferences = true
constructor (
protected i18n: I18n,
sort: this.sort,
categoryOneOf: this.categoryOneOf,
languageOneOf: this.languageOneOf,
+ nsfwPolicy: this.nsfwPolicy,
skipCount: true
}