diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2018-10-12 18:12:39 +0200 |
---|---|---|
committer | Rigel Kent <sendmemail@rigelk.eu> | 2018-10-13 11:53:48 +0200 |
commit | ed638e5325096ef580da20f370ac61c59cd48cf7 (patch) | |
tree | 8ad4c1001efb3adc3946a6b6c9a3c1ed1f557995 /client/src | |
parent | 64cc5e8575fda47b281ae20abf0020e27fc8ce7c (diff) | |
download | PeerTube-ed638e5325096ef580da20f370ac61c59cd48cf7.tar.gz PeerTube-ed638e5325096ef580da20f370ac61c59cd48cf7.tar.zst PeerTube-ed638e5325096ef580da20f370ac61c59cd48cf7.zip |
move to boolean switch
Diffstat (limited to 'client/src')
6 files changed, 26 insertions, 27 deletions
diff --git a/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html b/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html index adbb97f00..50f798c79 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html +++ b/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html | |||
@@ -16,18 +16,22 @@ | |||
16 | </div> | 16 | </div> |
17 | 17 | ||
18 | <div class="form-group"> | 18 | <div class="form-group"> |
19 | <label i18n for="webTorrentPolicy">Policy regarding P2P technologies</label> | 19 | <label i18n for="webTorrentEnabled">Policy regarding P2P technologies</label> |
20 | 20 | ||
21 | <div class="peertube-select-container"> | 21 | <div class="peertube-select-container"> |
22 | <select id="webTorrentPolicy" formControlName="webTorrentPolicy"> | 22 | <select id="webTorrentEnabled" formControlName="webTorrentEnabled"> |
23 | <option i18n value="enable">Enable WebTorrent</option> | 23 | <option i18n value="enable">Enable WebTorrent</option> |
24 | <option i18n value="disable">Disable WebTorrent globally</option> | 24 | <option i18n value="disable">Disable WebTorrent</option> |
25 | <option i18n value="disable_on_mobile" disabled>Disable WebTorrent on mobile devices (not yet available)</option> | ||
26 | </select> | 25 | </select> |
27 | </div> | 26 | </div> |
28 | </div> | 27 | </div> |
29 | 28 | ||
30 | <my-peertube-checkbox | 29 | <my-peertube-checkbox |
30 | inputName="webTorrentEnabled" formControlName="webTorrentEnabled" | ||
31 | i18n-labelText labelText="Use WebTorrent to exchange parts of the video with others" | ||
32 | ></my-peertube-checkbox> | ||
33 | |||
34 | <my-peertube-checkbox | ||
31 | inputName="autoPlayVideo" formControlName="autoPlayVideo" | 35 | inputName="autoPlayVideo" formControlName="autoPlayVideo" |
32 | i18n-labelText labelText="Automatically plays video" | 36 | i18n-labelText labelText="Automatically plays video" |
33 | ></my-peertube-checkbox> | 37 | ></my-peertube-checkbox> |
diff --git a/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.ts b/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.ts index 9e711a227..6c9a7ce75 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.ts | |||
@@ -29,14 +29,14 @@ export class MyAccountVideoSettingsComponent extends FormReactive implements OnI | |||
29 | ngOnInit () { | 29 | ngOnInit () { |
30 | this.buildForm({ | 30 | this.buildForm({ |
31 | nsfwPolicy: null, | 31 | nsfwPolicy: null, |
32 | webTorrentPolicy: null, | 32 | webTorrentEnabled: null, |
33 | autoPlayVideo: null | 33 | autoPlayVideo: null |
34 | }) | 34 | }) |
35 | 35 | ||
36 | this.userInformationLoaded.subscribe(() => { | 36 | this.userInformationLoaded.subscribe(() => { |
37 | this.form.patchValue({ | 37 | this.form.patchValue({ |
38 | nsfwPolicy: this.user.nsfwPolicy, | 38 | nsfwPolicy: this.user.nsfwPolicy, |
39 | webTorrentPolicy: this.user.webTorrentPolicy, | 39 | webTorrentEnabled: this.user.webTorrentEnabled, |
40 | autoPlayVideo: this.user.autoPlayVideo === true | 40 | autoPlayVideo: this.user.autoPlayVideo === true |
41 | }) | 41 | }) |
42 | }) | 42 | }) |
@@ -44,11 +44,11 @@ export class MyAccountVideoSettingsComponent extends FormReactive implements OnI | |||
44 | 44 | ||
45 | updateDetails () { | 45 | updateDetails () { |
46 | const nsfwPolicy = this.form.value['nsfwPolicy'] | 46 | const nsfwPolicy = this.form.value['nsfwPolicy'] |
47 | const webTorrentPolicy = this.form.value['webTorrentPolicy'] | 47 | const webTorrentEnabled = this.form.value['webTorrentEnabled'] |
48 | const autoPlayVideo = this.form.value['autoPlayVideo'] | 48 | const autoPlayVideo = this.form.value['autoPlayVideo'] |
49 | const details: UserUpdateMe = { | 49 | const details: UserUpdateMe = { |
50 | nsfwPolicy, | 50 | nsfwPolicy, |
51 | webTorrentPolicy, | 51 | webTorrentEnabled, |
52 | autoPlayVideo | 52 | autoPlayVideo |
53 | } | 53 | } |
54 | 54 | ||
diff --git a/client/src/app/core/auth/auth-user.model.ts b/client/src/app/core/auth/auth-user.model.ts index 97acf7bfe..acd13d9c5 100644 --- a/client/src/app/core/auth/auth-user.model.ts +++ b/client/src/app/core/auth/auth-user.model.ts | |||
@@ -4,7 +4,6 @@ import { UserRight } from '../../../../../shared/models/users/user-right.enum' | |||
4 | import { hasUserRight, UserRole } from '../../../../../shared/models/users/user-role' | 4 | import { hasUserRight, UserRole } from '../../../../../shared/models/users/user-role' |
5 | import { User, UserConstructorHash } from '../../shared/users/user.model' | 5 | import { User, UserConstructorHash } from '../../shared/users/user.model' |
6 | import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' | 6 | import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' |
7 | import { WebTorrentPolicyType } from '../../../../../shared/models/users/user-webtorrent-policy.type' | ||
8 | 7 | ||
9 | export type TokenOptions = { | 8 | export type TokenOptions = { |
10 | accessToken: string | 9 | accessToken: string |
@@ -73,7 +72,7 @@ export class AuthUser extends User { | |||
73 | EMAIL: 'email', | 72 | EMAIL: 'email', |
74 | USERNAME: 'username', | 73 | USERNAME: 'username', |
75 | NSFW_POLICY: 'nsfw_policy', | 74 | NSFW_POLICY: 'nsfw_policy', |
76 | WEBTORRENT_POLICY: 'peertube-videojs-' + 'webtorrent_policy', | 75 | WEBTORRENT_ENABLED: 'peertube-videojs-' + 'webtorrent_enabled', |
77 | AUTO_PLAY_VIDEO: 'auto_play_video' | 76 | AUTO_PLAY_VIDEO: 'auto_play_video' |
78 | } | 77 | } |
79 | 78 | ||
@@ -89,7 +88,7 @@ export class AuthUser extends User { | |||
89 | email: peertubeLocalStorage.getItem(this.KEYS.EMAIL), | 88 | email: peertubeLocalStorage.getItem(this.KEYS.EMAIL), |
90 | role: parseInt(peertubeLocalStorage.getItem(this.KEYS.ROLE), 10) as UserRole, | 89 | role: parseInt(peertubeLocalStorage.getItem(this.KEYS.ROLE), 10) as UserRole, |
91 | nsfwPolicy: peertubeLocalStorage.getItem(this.KEYS.NSFW_POLICY) as NSFWPolicyType, | 90 | nsfwPolicy: peertubeLocalStorage.getItem(this.KEYS.NSFW_POLICY) as NSFWPolicyType, |
92 | webTorrentPolicy: peertubeLocalStorage.getItem(this.KEYS.WEBTORRENT_POLICY) as WebTorrentPolicyType, | 91 | webTorrentEnabled: peertubeLocalStorage.getItem(this.KEYS.WEBTORRENT_ENABLED) === 'true', |
93 | autoPlayVideo: peertubeLocalStorage.getItem(this.KEYS.AUTO_PLAY_VIDEO) === 'true' | 92 | autoPlayVideo: peertubeLocalStorage.getItem(this.KEYS.AUTO_PLAY_VIDEO) === 'true' |
94 | }, | 93 | }, |
95 | Tokens.load() | 94 | Tokens.load() |
@@ -104,7 +103,7 @@ export class AuthUser extends User { | |||
104 | peertubeLocalStorage.removeItem(this.KEYS.ID) | 103 | peertubeLocalStorage.removeItem(this.KEYS.ID) |
105 | peertubeLocalStorage.removeItem(this.KEYS.ROLE) | 104 | peertubeLocalStorage.removeItem(this.KEYS.ROLE) |
106 | peertubeLocalStorage.removeItem(this.KEYS.NSFW_POLICY) | 105 | peertubeLocalStorage.removeItem(this.KEYS.NSFW_POLICY) |
107 | peertubeLocalStorage.removeItem(this.KEYS.WEBTORRENT_POLICY) | 106 | peertubeLocalStorage.removeItem(this.KEYS.WEBTORRENT_ENABLED) |
108 | peertubeLocalStorage.removeItem(this.KEYS.AUTO_PLAY_VIDEO) | 107 | peertubeLocalStorage.removeItem(this.KEYS.AUTO_PLAY_VIDEO) |
109 | peertubeLocalStorage.removeItem(this.KEYS.EMAIL) | 108 | peertubeLocalStorage.removeItem(this.KEYS.EMAIL) |
110 | Tokens.flush() | 109 | Tokens.flush() |
@@ -142,7 +141,7 @@ export class AuthUser extends User { | |||
142 | peertubeLocalStorage.setItem(AuthUser.KEYS.EMAIL, this.email) | 141 | peertubeLocalStorage.setItem(AuthUser.KEYS.EMAIL, this.email) |
143 | peertubeLocalStorage.setItem(AuthUser.KEYS.ROLE, this.role.toString()) | 142 | peertubeLocalStorage.setItem(AuthUser.KEYS.ROLE, this.role.toString()) |
144 | peertubeLocalStorage.setItem(AuthUser.KEYS.NSFW_POLICY, this.nsfwPolicy.toString()) | 143 | peertubeLocalStorage.setItem(AuthUser.KEYS.NSFW_POLICY, this.nsfwPolicy.toString()) |
145 | peertubeLocalStorage.setItem(AuthUser.KEYS.WEBTORRENT_POLICY, this.webTorrentPolicy.toString()) | 144 | peertubeLocalStorage.setItem(AuthUser.KEYS.WEBTORRENT_ENABLED, JSON.stringify(this.webTorrentEnabled)) |
146 | peertubeLocalStorage.setItem(AuthUser.KEYS.AUTO_PLAY_VIDEO, JSON.stringify(this.autoPlayVideo)) | 145 | peertubeLocalStorage.setItem(AuthUser.KEYS.AUTO_PLAY_VIDEO, JSON.stringify(this.autoPlayVideo)) |
147 | this.tokens.save() | 146 | this.tokens.save() |
148 | } | 147 | } |
diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts index 240c7aacf..7c840ffa7 100644 --- a/client/src/app/shared/users/user.model.ts +++ b/client/src/app/shared/users/user.model.ts | |||
@@ -9,7 +9,6 @@ import { | |||
9 | import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' | 9 | import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' |
10 | import { Account } from '@app/shared/account/account.model' | 10 | import { Account } from '@app/shared/account/account.model' |
11 | import { Avatar } from '../../../../../shared/models/avatars/avatar.model' | 11 | import { Avatar } from '../../../../../shared/models/avatars/avatar.model' |
12 | import { WebTorrentPolicyType } from '../../../../../shared/models/users/user-webtorrent-policy.type' | ||
13 | 12 | ||
14 | export type UserConstructorHash = { | 13 | export type UserConstructorHash = { |
15 | id: number, | 14 | id: number, |
@@ -19,7 +18,7 @@ export type UserConstructorHash = { | |||
19 | videoQuota?: number, | 18 | videoQuota?: number, |
20 | videoQuotaDaily?: number, | 19 | videoQuotaDaily?: number, |
21 | nsfwPolicy?: NSFWPolicyType, | 20 | nsfwPolicy?: NSFWPolicyType, |
22 | webTorrentPolicy?: WebTorrentPolicyType, | 21 | webTorrentEnabled?: boolean, |
23 | autoPlayVideo?: boolean, | 22 | autoPlayVideo?: boolean, |
24 | createdAt?: Date, | 23 | createdAt?: Date, |
25 | account?: AccountServerModel, | 24 | account?: AccountServerModel, |
@@ -34,7 +33,7 @@ export class User implements UserServerModel { | |||
34 | email: string | 33 | email: string |
35 | role: UserRole | 34 | role: UserRole |
36 | nsfwPolicy: NSFWPolicyType | 35 | nsfwPolicy: NSFWPolicyType |
37 | webTorrentPolicy: WebTorrentPolicyType | 36 | webTorrentEnabled: boolean |
38 | autoPlayVideo: boolean | 37 | autoPlayVideo: boolean |
39 | videoQuota: number | 38 | videoQuota: number |
40 | videoQuotaDaily: number | 39 | videoQuotaDaily: number |
@@ -55,7 +54,7 @@ export class User implements UserServerModel { | |||
55 | this.videoQuota = hash.videoQuota | 54 | this.videoQuota = hash.videoQuota |
56 | this.videoQuotaDaily = hash.videoQuotaDaily | 55 | this.videoQuotaDaily = hash.videoQuotaDaily |
57 | this.nsfwPolicy = hash.nsfwPolicy | 56 | this.nsfwPolicy = hash.nsfwPolicy |
58 | this.webTorrentPolicy = hash.webTorrentPolicy | 57 | this.webTorrentEnabled = hash.webTorrentEnabled |
59 | this.autoPlayVideo = hash.autoPlayVideo | 58 | this.autoPlayVideo = hash.autoPlayVideo |
60 | this.createdAt = hash.createdAt | 59 | this.createdAt = hash.createdAt |
61 | this.blocked = hash.blocked | 60 | this.blocked = hash.blocked |
diff --git a/client/src/assets/player/peertube-player-local-storage.ts b/client/src/assets/player/peertube-player-local-storage.ts index c3d8b71bc..3ac5fe58a 100644 --- a/client/src/assets/player/peertube-player-local-storage.ts +++ b/client/src/assets/player/peertube-player-local-storage.ts | |||
@@ -10,13 +10,11 @@ function getStoredVolume () { | |||
10 | return undefined | 10 | return undefined |
11 | } | 11 | } |
12 | 12 | ||
13 | function getStoredWebTorrentPolicy () { | 13 | function getStoredWebTorrentEnabled (): boolean { |
14 | const value = getLocalStorage('webtorrent_policy') | 14 | const value = getLocalStorage('webtorrent_enabled') |
15 | if (value !== null && value !== undefined) { | 15 | if (value !== null && value !== undefined) return value === 'true' |
16 | if (value.toString() === 'disable') return true | ||
17 | } | ||
18 | 16 | ||
19 | return undefined | 17 | return false |
20 | } | 18 | } |
21 | 19 | ||
22 | function getStoredMute () { | 20 | function getStoredMute () { |
@@ -65,7 +63,7 @@ function getAverageBandwidthInStore () { | |||
65 | 63 | ||
66 | export { | 64 | export { |
67 | getStoredVolume, | 65 | getStoredVolume, |
68 | getStoredWebTorrentPolicy, | 66 | getStoredWebTorrentEnabled, |
69 | getStoredMute, | 67 | getStoredMute, |
70 | getStoredTheater, | 68 | getStoredTheater, |
71 | saveVolumeInStore, | 69 | saveVolumeInStore, |
diff --git a/client/src/assets/player/peertube-videojs-plugin.ts b/client/src/assets/player/peertube-videojs-plugin.ts index 90ca8f9fa..a53a2cc69 100644 --- a/client/src/assets/player/peertube-videojs-plugin.ts +++ b/client/src/assets/player/peertube-videojs-plugin.ts | |||
@@ -8,7 +8,7 @@ import { isMobile, timeToInt, videoFileMaxByResolution, videoFileMinByResolution | |||
8 | import * as CacheChunkStore from 'cache-chunk-store' | 8 | import * as CacheChunkStore from 'cache-chunk-store' |
9 | import { PeertubeChunkStore } from './peertube-chunk-store' | 9 | import { PeertubeChunkStore } from './peertube-chunk-store' |
10 | import { | 10 | import { |
11 | getStoredWebTorrentPolicy, | 11 | getStoredWebTorrentEnabled, |
12 | getAverageBandwidthInStore, | 12 | getAverageBandwidthInStore, |
13 | getStoredMute, | 13 | getStoredMute, |
14 | getStoredVolume, | 14 | getStoredVolume, |
@@ -82,6 +82,7 @@ class PeerTubePlugin extends Plugin { | |||
82 | 82 | ||
83 | // Disable auto play on iOS | 83 | // Disable auto play on iOS |
84 | this.autoplay = options.autoplay && this.isIOS() === false | 84 | this.autoplay = options.autoplay && this.isIOS() === false |
85 | this.playerRefusedP2P = !getStoredWebTorrentEnabled() | ||
85 | 86 | ||
86 | this.startTime = timeToInt(options.startTime) | 87 | this.startTime = timeToInt(options.startTime) |
87 | this.videoFiles = options.videoFiles | 88 | this.videoFiles = options.videoFiles |
@@ -99,7 +100,6 @@ class PeerTubePlugin extends Plugin { | |||
99 | if (volume !== undefined) this.player.volume(volume) | 100 | if (volume !== undefined) this.player.volume(volume) |
100 | const muted = getStoredMute() | 101 | const muted = getStoredMute() |
101 | if (muted !== undefined) this.player.muted(muted) | 102 | if (muted !== undefined) this.player.muted(muted) |
102 | this.playerRefusedP2P = getStoredWebTorrentPolicy() || false | ||
103 | 103 | ||
104 | this.initializePlayer() | 104 | this.initializePlayer() |
105 | this.runTorrentInfoScheduler() | 105 | this.runTorrentInfoScheduler() |
@@ -291,7 +291,6 @@ class PeerTubePlugin extends Plugin { | |||
291 | renderVideo(torrent.files[ 0 ], this.playerElement, renderVideoOptions, (err, renderer) => { | 291 | renderVideo(torrent.files[ 0 ], this.playerElement, renderVideoOptions, (err, renderer) => { |
292 | this.renderer = renderer | 292 | this.renderer = renderer |
293 | 293 | ||
294 | console.log('value this.playerRefusedP2P', this.playerRefusedP2P) | ||
295 | if (err || this.playerRefusedP2P) return this.fallbackToHttp(done) | 294 | if (err || this.playerRefusedP2P) return this.fallbackToHttp(done) |
296 | 295 | ||
297 | return this.tryToPlay(err => { | 296 | return this.tryToPlay(err => { |