From a5cf76afa378aae81af2a9b0ce548e5d2582f832 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 25 Sep 2020 10:04:21 +0200 Subject: Add watch messages if live has not started --- .../app/shared/shared-main/shared-main.module.ts | 4 ++-- .../shared-main/users/user-notification.service.ts | 10 ++++---- client/src/app/shared/shared-main/video/index.ts | 2 +- .../shared/shared-main/video/live-video.service.ts | 28 ++++++++++++++++++++++ .../shared/shared-main/video/video-live.service.ts | 28 ---------------------- .../shared-share-modal/video-share.component.html | 6 ++--- .../video-actions-dropdown.component.ts | 5 +++- 7 files changed, 43 insertions(+), 40 deletions(-) create mode 100644 client/src/app/shared/shared-main/video/live-video.service.ts delete mode 100644 client/src/app/shared/shared-main/video/video-live.service.ts (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/shared-main/shared-main.module.ts b/client/src/app/shared/shared-main/shared-main.module.ts index bca67b193..0580872f4 100644 --- a/client/src/app/shared/shared-main/shared-main.module.ts +++ b/client/src/app/shared/shared-main/shared-main.module.ts @@ -23,7 +23,7 @@ import { FeedComponent } from './feeds' import { LoaderComponent, SmallLoaderComponent } from './loaders' import { HelpComponent, ListOverflowComponent, TopMenuDropdownComponent } from './misc' import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users' -import { RedundancyService, VideoImportService, VideoOwnershipService, VideoService, VideoLiveService } from './video' +import { RedundancyService, VideoImportService, VideoOwnershipService, VideoService, LiveVideoService } from './video' import { VideoCaptionService } from './video-caption' import { VideoChannelService } from './video-channel' @@ -142,7 +142,7 @@ import { VideoChannelService } from './video-channel' RedundancyService, VideoImportService, VideoOwnershipService, - VideoLiveService, + LiveVideoService, VideoService, VideoCaptionService, diff --git a/client/src/app/shared/shared-main/users/user-notification.service.ts b/client/src/app/shared/shared-main/users/user-notification.service.ts index 7b9dc34be..9014b48a8 100644 --- a/client/src/app/shared/shared-main/users/user-notification.service.ts +++ b/client/src/app/shared/shared-main/users/user-notification.service.ts @@ -1,7 +1,7 @@ import { catchError, map, tap } from 'rxjs/operators' import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' -import { ComponentPaginationLight, RestExtractor, RestService, User, UserNotificationSocket, AuthService } from '@app/core' +import { ComponentPaginationLight, RestExtractor, RestService, User, PeerTubeSocket, AuthService } from '@app/core' import { ResultList, UserNotification as UserNotificationServer, UserNotificationSetting } from '@shared/models' import { environment } from '../../../../environments/environment' import { UserNotification } from './user-notification.model' @@ -17,7 +17,7 @@ export class UserNotificationService { private auth: AuthService, private restExtractor: RestExtractor, private restService: RestService, - private userNotificationSocket: UserNotificationSocket + private peertubeSocket: PeerTubeSocket ) {} listMyNotifications (parameters: { @@ -57,7 +57,7 @@ export class UserNotificationService { return this.authHttp.post(url, body, { headers }) .pipe( map(this.restExtractor.extractDataBool), - tap(() => this.userNotificationSocket.dispatch('read')), + tap(() => this.peertubeSocket.dispatchNotificationEvent('read')), catchError(res => this.restExtractor.handleError(res)) ) } @@ -69,12 +69,12 @@ export class UserNotificationService { return this.authHttp.post(url, {}, { headers }) .pipe( map(this.restExtractor.extractDataBool), - tap(() => this.userNotificationSocket.dispatch('read-all')), + tap(() => this.peertubeSocket.dispatchNotificationEvent('read-all')), catchError(res => this.restExtractor.handleError(res)) ) } - updateNotificationSettings (user: User, settings: UserNotificationSetting) { + updateNotificationSettings (settings: UserNotificationSetting) { const url = UserNotificationService.BASE_NOTIFICATION_SETTINGS return this.authHttp.put(url, settings) diff --git a/client/src/app/shared/shared-main/video/index.ts b/client/src/app/shared/shared-main/video/index.ts index 121635a30..f69089517 100644 --- a/client/src/app/shared/shared-main/video/index.ts +++ b/client/src/app/shared/shared-main/video/index.ts @@ -1,8 +1,8 @@ +export * from './live-video.service' export * from './redundancy.service' export * from './video-details.model' export * from './video-edit.model' export * from './video-import.service' -export * from './video-live.service' export * from './video-ownership.service' export * from './video.model' export * from './video.service' diff --git a/client/src/app/shared/shared-main/video/live-video.service.ts b/client/src/app/shared/shared-main/video/live-video.service.ts new file mode 100644 index 000000000..2cd1c66a5 --- /dev/null +++ b/client/src/app/shared/shared-main/video/live-video.service.ts @@ -0,0 +1,28 @@ +import { catchError } from 'rxjs/operators' +import { HttpClient } from '@angular/common/http' +import { Injectable } from '@angular/core' +import { RestExtractor } from '@app/core' +import { VideoCreate, LiveVideo } from '@shared/models' +import { environment } from '../../../../environments/environment' + +@Injectable() +export class LiveVideoService { + static BASE_VIDEO_LIVE_URL = environment.apiUrl + '/api/v1/videos/live/' + + constructor ( + private authHttp: HttpClient, + private restExtractor: RestExtractor + ) {} + + goLive (video: VideoCreate) { + return this.authHttp + .post<{ video: { id: number, uuid: string } }>(LiveVideoService.BASE_VIDEO_LIVE_URL, video) + .pipe(catchError(err => this.restExtractor.handleError(err))) + } + + getVideoLive (videoId: number | string) { + return this.authHttp + .get(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId) + .pipe(catchError(err => this.restExtractor.handleError(err))) + } +} diff --git a/client/src/app/shared/shared-main/video/video-live.service.ts b/client/src/app/shared/shared-main/video/video-live.service.ts deleted file mode 100644 index 12daff756..000000000 --- a/client/src/app/shared/shared-main/video/video-live.service.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { catchError } from 'rxjs/operators' -import { HttpClient } from '@angular/common/http' -import { Injectable } from '@angular/core' -import { RestExtractor } from '@app/core' -import { VideoCreate, VideoLive } from '@shared/models' -import { environment } from '../../../../environments/environment' - -@Injectable() -export class VideoLiveService { - static BASE_VIDEO_LIVE_URL = environment.apiUrl + '/api/v1/videos/live/' - - constructor ( - private authHttp: HttpClient, - private restExtractor: RestExtractor - ) {} - - goLive (video: VideoCreate) { - return this.authHttp - .post<{ video: { id: number, uuid: string } }>(VideoLiveService.BASE_VIDEO_LIVE_URL, video) - .pipe(catchError(err => this.restExtractor.handleError(err))) - } - - getVideoLive (videoId: number | string) { - return this.authHttp - .get(VideoLiveService.BASE_VIDEO_LIVE_URL + videoId) - .pipe(catchError(err => this.restExtractor.handleError(err))) - } -} diff --git a/client/src/app/shared/shared-share-modal/video-share.component.html b/client/src/app/shared/shared-share-modal/video-share.component.html index 3222dc5a6..80b4e446a 100644 --- a/client/src/app/shared/shared-share-modal/video-share.component.html +++ b/client/src/app/shared/shared-share-modal/video-share.component.html @@ -107,7 +107,7 @@
-
+
-
+
-
+