diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/src/app/shared/shared-user-settings/user-video-settings.component.ts | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/client/src/app/shared/shared-user-settings/user-video-settings.component.ts b/client/src/app/shared/shared-user-settings/user-video-settings.component.ts index ab77f6f9c..2497e001c 100644 --- a/client/src/app/shared/shared-user-settings/user-video-settings.component.ts +++ b/client/src/app/shared/shared-user-settings/user-video-settings.component.ts | |||
@@ -95,27 +95,22 @@ export class UserVideoSettingsComponent extends FormReactive implements OnInit, | |||
95 | const autoPlayVideo = this.form.value['autoPlayVideo'] | 95 | const autoPlayVideo = this.form.value['autoPlayVideo'] |
96 | const autoPlayNextVideo = this.form.value['autoPlayNextVideo'] | 96 | const autoPlayNextVideo = this.form.value['autoPlayNextVideo'] |
97 | 97 | ||
98 | let videoLanguages: string[] = this.form.value['videoLanguages'] | 98 | const videoLanguagesForm = this.form.value['videoLanguages'] |
99 | 99 | ||
100 | if (Array.isArray(videoLanguages)) { | 100 | if (Array.isArray(videoLanguagesForm)) { |
101 | if (videoLanguages.length > 20) { | 101 | if (videoLanguagesForm.length > 20) { |
102 | this.notifier.error($localize`Too many languages are enabled. Please enable them all or stay below 20 enabled languages.`) | 102 | this.notifier.error($localize`Too many languages are enabled. Please enable them all or stay below 20 enabled languages.`) |
103 | return | 103 | return |
104 | } | 104 | } |
105 | 105 | ||
106 | if (videoLanguages.length === 0) { | 106 | if (videoLanguagesForm.length === 0) { |
107 | this.notifier.error($localize`You need to enable at least 1 video language.`) | 107 | this.notifier.error($localize`You need to enable at least 1 video language.`) |
108 | return | 108 | return |
109 | } | 109 | } |
110 | |||
111 | if ( | ||
112 | videoLanguages.length === this.languageItems.length || | ||
113 | (videoLanguages.length === 1 && videoLanguages[0] === this.allLanguagesGroup) | ||
114 | ) { | ||
115 | videoLanguages = null // null means "All" | ||
116 | } | ||
117 | } | 110 | } |
118 | 111 | ||
112 | const videoLanguages = this.getVideoLanguages(videoLanguagesForm) | ||
113 | |||
119 | let details: UserUpdateMe = { | 114 | let details: UserUpdateMe = { |
120 | nsfwPolicy, | 115 | nsfwPolicy, |
121 | webTorrentEnabled, | 116 | webTorrentEnabled, |
@@ -124,6 +119,10 @@ export class UserVideoSettingsComponent extends FormReactive implements OnInit, | |||
124 | videoLanguages | 119 | videoLanguages |
125 | } | 120 | } |
126 | 121 | ||
122 | if (videoLanguages) { | ||
123 | details = Object.assign(details, videoLanguages) | ||
124 | } | ||
125 | |||
127 | if (onlyKeys) details = pick(details, onlyKeys) | 126 | if (onlyKeys) details = pick(details, onlyKeys) |
128 | 127 | ||
129 | if (this.authService.isLoggedIn()) { | 128 | if (this.authService.isLoggedIn()) { |
@@ -141,4 +140,29 @@ export class UserVideoSettingsComponent extends FormReactive implements OnInit, | |||
141 | if (this.notifyOnUpdate) this.notifier.success($localize`Display/Video settings updated.`) | 140 | if (this.notifyOnUpdate) this.notifier.success($localize`Display/Video settings updated.`) |
142 | } | 141 | } |
143 | } | 142 | } |
143 | |||
144 | private getVideoLanguages (videoLanguages: ItemSelectCheckboxValue[]) { | ||
145 | if (!Array.isArray(videoLanguages)) return undefined | ||
146 | |||
147 | // null means "All" | ||
148 | if (videoLanguages.length === this.languageItems.length) return null | ||
149 | |||
150 | if (videoLanguages.length === 1) { | ||
151 | const videoLanguage = videoLanguages[0] | ||
152 | |||
153 | if (typeof videoLanguage === 'string') { | ||
154 | if (videoLanguage === this.allLanguagesGroup) return null | ||
155 | } else { | ||
156 | if (videoLanguage.group === this.allLanguagesGroup) return null | ||
157 | } | ||
158 | } | ||
159 | |||
160 | return videoLanguages.map(l => { | ||
161 | if (typeof l === 'string') return l | ||
162 | |||
163 | if (l.group) return l.group | ||
164 | |||
165 | return l.id + '' | ||
166 | }) | ||
167 | } | ||
144 | } | 168 | } |