diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-26 14:12:39 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-26 14:12:50 +0200 |
commit | 9162fdd36300d2478f13d6ad346ec2c323f40faa (patch) | |
tree | dea0ca43f3ea2fb72a73ca77338f5b7c990acdd7 /client/src/app/shared/shared-share-modal | |
parent | 764b1a14fc494f2cfd7ea590d2f07b01df65c7ad (diff) | |
download | PeerTube-9162fdd36300d2478f13d6ad346ec2c323f40faa.tar.gz PeerTube-9162fdd36300d2478f13d6ad346ec2c323f40faa.tar.zst PeerTube-9162fdd36300d2478f13d6ad346ec2c323f40faa.zip |
Refactor video links building
Diffstat (limited to 'client/src/app/shared/shared-share-modal')
-rw-r--r-- | client/src/app/shared/shared-share-modal/video-share.component.ts | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/client/src/app/shared/shared-share-modal/video-share.component.ts b/client/src/app/shared/shared-share-modal/video-share.component.ts index a41ff248b..cdfe50836 100644 --- a/client/src/app/shared/shared-share-modal/video-share.component.ts +++ b/client/src/app/shared/shared-share-modal/video-share.component.ts | |||
@@ -1,9 +1,15 @@ | |||
1 | import { Component, ElementRef, Input, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, Input, ViewChild } from '@angular/core' |
2 | import { Video, VideoDetails } from '@app/shared/shared-main' | 2 | import { VideoDetails } from '@app/shared/shared-main' |
3 | import { VideoPlaylist } from '@app/shared/shared-video-playlist' | 3 | import { VideoPlaylist } from '@app/shared/shared-video-playlist' |
4 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 4 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
5 | import { VideoCaption } from '@shared/models' | 5 | import { VideoCaption } from '@shared/models' |
6 | import { buildPlaylistLink, buildVideoLink, buildVideoOrPlaylistEmbed } from '../../../assets/player/utils' | 6 | import { |
7 | buildPlaylistLink, | ||
8 | buildVideoLink, | ||
9 | buildVideoOrPlaylistEmbed, | ||
10 | decoratePlaylistLink, | ||
11 | decorateVideoLink | ||
12 | } from '../../../assets/player/utils' | ||
7 | 13 | ||
8 | type Customizations = { | 14 | type Customizations = { |
9 | startAtCheckbox: boolean | 15 | startAtCheckbox: boolean |
@@ -83,34 +89,34 @@ export class VideoShareComponent { | |||
83 | } | 89 | } |
84 | 90 | ||
85 | getVideoIframeCode () { | 91 | getVideoIframeCode () { |
86 | const options = this.getVideoOptions(this.video.embedUrl) | 92 | const embedUrl = decorateVideoLink({ url: this.video.embedUrl, ...this.getVideoOptions() }) |
87 | 93 | ||
88 | const embedUrl = buildVideoLink(options) | ||
89 | return buildVideoOrPlaylistEmbed(embedUrl, this.video.name) | 94 | return buildVideoOrPlaylistEmbed(embedUrl, this.video.name) |
90 | } | 95 | } |
91 | 96 | ||
92 | getPlaylistIframeCode () { | 97 | getPlaylistIframeCode () { |
93 | const options = this.getPlaylistOptions(this.playlist.embedUrl) | 98 | const embedUrl = decoratePlaylistLink({ url: this.playlist.embedUrl, ...this.getPlaylistOptions() }) |
94 | 99 | ||
95 | const embedUrl = buildPlaylistLink(options) | ||
96 | return buildVideoOrPlaylistEmbed(embedUrl, this.playlist.displayName) | 100 | return buildVideoOrPlaylistEmbed(embedUrl, this.playlist.displayName) |
97 | } | 101 | } |
98 | 102 | ||
99 | getVideoUrl () { | 103 | getVideoUrl () { |
100 | let baseUrl = this.customizations.originUrl ? this.video.originInstanceUrl : window.location.origin | 104 | const baseUrl = this.customizations.originUrl |
101 | baseUrl += Video.buildWatchUrl(this.video) | 105 | ? this.video.originInstanceUrl |
106 | : window.location.origin | ||
102 | 107 | ||
103 | const options = this.getVideoOptions(baseUrl) | 108 | return decorateVideoLink({ |
109 | url: buildVideoLink(this.video, baseUrl), | ||
104 | 110 | ||
105 | return buildVideoLink(options) | 111 | ...this.getVideoOptions() |
112 | }) | ||
106 | } | 113 | } |
107 | 114 | ||
108 | getPlaylistUrl () { | 115 | getPlaylistUrl () { |
109 | const base = window.location.origin + VideoPlaylist.buildWatchUrl(this.playlist) | 116 | const url = buildPlaylistLink(this.playlist) |
117 | if (!this.includeVideoInPlaylist) return url | ||
110 | 118 | ||
111 | if (!this.includeVideoInPlaylist) return base | 119 | return decoratePlaylistLink({ url, playlistPosition: this.playlistPosition }) |
112 | |||
113 | return base + '?playlistPosition=' + this.playlistPosition | ||
114 | } | 120 | } |
115 | 121 | ||
116 | notSecure () { | 122 | notSecure () { |
@@ -133,10 +139,8 @@ export class VideoShareComponent { | |||
133 | } | 139 | } |
134 | } | 140 | } |
135 | 141 | ||
136 | private getVideoOptions (baseUrl?: string) { | 142 | private getVideoOptions () { |
137 | return { | 143 | return { |
138 | baseUrl, | ||
139 | |||
140 | startTime: this.customizations.startAtCheckbox ? this.customizations.startAt : undefined, | 144 | startTime: this.customizations.startAtCheckbox ? this.customizations.startAt : undefined, |
141 | stopTime: this.customizations.stopAtCheckbox ? this.customizations.stopAt : undefined, | 145 | stopTime: this.customizations.stopAtCheckbox ? this.customizations.stopAt : undefined, |
142 | 146 | ||