diff options
author | Chocobozzz <me@florianbigard.com> | 2021-08-17 11:27:47 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-08-17 14:01:45 +0200 |
commit | 1378c0d343028f3d40d7d795422684ab9e6a1599 (patch) | |
tree | 08062b84a38a7e2dfe0aa674e7ca8e1b7321044e /client/src/app/core | |
parent | c186a67f90203af6bfa434f026efdc99193bcd65 (diff) | |
download | PeerTube-1378c0d343028f3d40d7d795422684ab9e6a1599.tar.gz PeerTube-1378c0d343028f3d40d7d795422684ab9e6a1599.tar.zst PeerTube-1378c0d343028f3d40d7d795422684ab9e6a1599.zip |
Fix client lint
Diffstat (limited to 'client/src/app/core')
-rw-r--r-- | client/src/app/core/auth/auth.service.ts | 40 | ||||
-rw-r--r-- | client/src/app/core/confirm/confirm.service.ts | 11 | ||||
-rw-r--r-- | client/src/app/core/plugins/plugin.service.ts | 17 | ||||
-rw-r--r-- | client/src/app/core/rest/rest-extractor.service.ts | 4 |
4 files changed, 35 insertions, 37 deletions
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index ef5a3808e..5da66c981 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts | |||
@@ -80,8 +80,8 @@ export class AuthService { | |||
80 | // Fetch the client_id/client_secret | 80 | // Fetch the client_id/client_secret |
81 | this.http.get<OAuthClientLocal>(AuthService.BASE_CLIENT_URL) | 81 | this.http.get<OAuthClientLocal>(AuthService.BASE_CLIENT_URL) |
82 | .pipe(catchError(res => this.restExtractor.handleError(res))) | 82 | .pipe(catchError(res => this.restExtractor.handleError(res))) |
83 | .subscribe( | 83 | .subscribe({ |
84 | res => { | 84 | next: res => { |
85 | this.clientId = res.client_id | 85 | this.clientId = res.client_id |
86 | this.clientSecret = res.client_secret | 86 | this.clientSecret = res.client_secret |
87 | 87 | ||
@@ -91,18 +91,18 @@ export class AuthService { | |||
91 | console.log('Client credentials loaded.') | 91 | console.log('Client credentials loaded.') |
92 | }, | 92 | }, |
93 | 93 | ||
94 | error => { | 94 | error: err => { |
95 | let errorMessage = error.message | 95 | let errorMessage = err.message |
96 | 96 | ||
97 | if (error.status === HttpStatusCode.FORBIDDEN_403) { | 97 | if (err.status === HttpStatusCode.FORBIDDEN_403) { |
98 | errorMessage = $localize`Cannot retrieve OAuth Client credentials: ${error.text}. | 98 | errorMessage = $localize`Cannot retrieve OAuth Client credentials: ${err.text}. |
99 | Ensure you have correctly configured PeerTube (config/ directory), in particular the "webserver" section.` | 99 | Ensure you have correctly configured PeerTube (config/ directory), in particular the "webserver" section.` |
100 | } | 100 | } |
101 | 101 | ||
102 | // We put a bigger timeout: this is an important message | 102 | // We put a bigger timeout: this is an important message |
103 | this.notifier.error(errorMessage, $localize`Error`, 7000) | 103 | this.notifier.error(errorMessage, $localize`Error`, 7000) |
104 | } | 104 | } |
105 | ) | 105 | }) |
106 | } | 106 | } |
107 | 107 | ||
108 | getRefreshToken () { | 108 | getRefreshToken () { |
@@ -168,15 +168,15 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular | |||
168 | const headers = new HttpHeaders().set('Authorization', authHeaderValue) | 168 | const headers = new HttpHeaders().set('Authorization', authHeaderValue) |
169 | 169 | ||
170 | this.http.post<{ redirectUrl?: string }>(AuthService.BASE_REVOKE_TOKEN_URL, {}, { headers }) | 170 | this.http.post<{ redirectUrl?: string }>(AuthService.BASE_REVOKE_TOKEN_URL, {}, { headers }) |
171 | .subscribe( | 171 | .subscribe({ |
172 | res => { | 172 | next: res => { |
173 | if (res.redirectUrl) { | 173 | if (res.redirectUrl) { |
174 | window.location.href = res.redirectUrl | 174 | window.location.href = res.redirectUrl |
175 | } | 175 | } |
176 | }, | 176 | }, |
177 | 177 | ||
178 | err => console.error(err) | 178 | error: err => console.error(err) |
179 | ) | 179 | }) |
180 | 180 | ||
181 | this.user = null | 181 | this.user = null |
182 | 182 | ||
@@ -215,9 +215,9 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular | |||
215 | this.logout() | 215 | this.logout() |
216 | this.router.navigate([ '/login' ]) | 216 | this.router.navigate([ '/login' ]) |
217 | 217 | ||
218 | return observableThrowError({ | 218 | return observableThrowError(() => ({ |
219 | error: $localize`You need to reconnect.` | 219 | error: $localize`You need to reconnect.` |
220 | }) | 220 | })) |
221 | }), | 221 | }), |
222 | share() | 222 | share() |
223 | ) | 223 | ) |
@@ -234,14 +234,14 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular | |||
234 | } | 234 | } |
235 | 235 | ||
236 | this.mergeUserInformation(obj) | 236 | this.mergeUserInformation(obj) |
237 | .subscribe( | 237 | .subscribe({ |
238 | res => { | 238 | next: res => { |
239 | this.user.patch(res) | 239 | this.user.patch(res) |
240 | this.user.save() | 240 | this.user.save() |
241 | 241 | ||
242 | this.userInformationLoaded.next(true) | 242 | this.userInformationLoaded.next(true) |
243 | } | 243 | } |
244 | ) | 244 | }) |
245 | } | 245 | } |
246 | 246 | ||
247 | private mergeUserInformation (obj: UserLoginWithUsername): Observable<UserLoginWithUserInformation> { | 247 | private mergeUserInformation (obj: UserLoginWithUsername): Observable<UserLoginWithUserInformation> { |
diff --git a/client/src/app/core/confirm/confirm.service.ts b/client/src/app/core/confirm/confirm.service.ts index 6e042c16b..338b8762c 100644 --- a/client/src/app/core/confirm/confirm.service.ts +++ b/client/src/app/core/confirm/confirm.service.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { first } from 'rxjs/operators' | 1 | import { firstValueFrom, Subject } from 'rxjs' |
2 | import { Injectable } from '@angular/core' | 2 | import { Injectable } from '@angular/core' |
3 | import { Subject } from 'rxjs' | ||
4 | 3 | ||
5 | type ConfirmOptions = { | 4 | type ConfirmOptions = { |
6 | title: string | 5 | title: string |
@@ -18,16 +17,12 @@ export class ConfirmService { | |||
18 | confirm (message: string, title = '', confirmButtonText?: string) { | 17 | confirm (message: string, title = '', confirmButtonText?: string) { |
19 | this.showConfirm.next({ title, message, confirmButtonText }) | 18 | this.showConfirm.next({ title, message, confirmButtonText }) |
20 | 19 | ||
21 | return this.confirmResponse.asObservable() | 20 | return firstValueFrom(this.confirmResponse.asObservable()) |
22 | .pipe(first()) | ||
23 | .toPromise() | ||
24 | } | 21 | } |
25 | 22 | ||
26 | confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '', confirmButtonText?: string) { | 23 | confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '', confirmButtonText?: string) { |
27 | this.showConfirm.next({ title, message, inputLabel, expectedInputValue, confirmButtonText }) | 24 | this.showConfirm.next({ title, message, inputLabel, expectedInputValue, confirmButtonText }) |
28 | 25 | ||
29 | return this.confirmResponse.asObservable() | 26 | return firstValueFrom(this.confirmResponse.asObservable()) |
30 | .pipe(first()) | ||
31 | .toPromise() | ||
32 | } | 27 | } |
33 | } | 28 | } |
diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts index 16108e17a..774c03964 100644 --- a/client/src/app/core/plugins/plugin.service.ts +++ b/client/src/app/core/plugins/plugin.service.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { Observable, of } from 'rxjs' | 1 | import { firstValueFrom, Observable, of } from 'rxjs' |
2 | import { catchError, map, shareReplay } from 'rxjs/operators' | 2 | import { catchError, map, shareReplay } from 'rxjs/operators' |
3 | import { HttpClient } from '@angular/common/http' | 3 | import { HttpClient } from '@angular/common/http' |
4 | import { Inject, Injectable, LOCALE_ID, NgZone } from '@angular/core' | 4 | import { Inject, Injectable, LOCALE_ID, NgZone } from '@angular/core' |
@@ -164,18 +164,20 @@ export class PluginService implements ClientHook { | |||
164 | getSettings: () => { | 164 | getSettings: () => { |
165 | const path = PluginService.BASE_PLUGIN_API_URL + '/' + npmName + '/public-settings' | 165 | const path = PluginService.BASE_PLUGIN_API_URL + '/' + npmName + '/public-settings' |
166 | 166 | ||
167 | return this.authHttp.get<PublicServerSetting>(path) | 167 | const obs = this.authHttp.get<PublicServerSetting>(path) |
168 | .pipe( | 168 | .pipe( |
169 | map(p => p.publicSettings), | 169 | map(p => p.publicSettings), |
170 | catchError(res => this.restExtractor.handleError(res)) | 170 | catchError(res => this.restExtractor.handleError(res)) |
171 | ) | 171 | ) |
172 | .toPromise() | 172 | |
173 | return firstValueFrom(obs) | ||
173 | }, | 174 | }, |
174 | 175 | ||
175 | getServerConfig: () => { | 176 | getServerConfig: () => { |
176 | return this.server.getConfig() | 177 | const obs = this.server.getConfig() |
177 | .pipe(catchError(res => this.restExtractor.handleError(res))) | 178 | .pipe(catchError(res => this.restExtractor.handleError(res))) |
178 | .toPromise() | 179 | |
180 | return firstValueFrom(obs) | ||
179 | }, | 181 | }, |
180 | 182 | ||
181 | isLoggedIn: () => { | 183 | isLoggedIn: () => { |
@@ -216,10 +218,11 @@ export class PluginService implements ClientHook { | |||
216 | }, | 218 | }, |
217 | 219 | ||
218 | translate: (value: string) => { | 220 | translate: (value: string) => { |
219 | return this.translationsObservable | 221 | const obs = this.translationsObservable |
220 | .pipe(map(allTranslations => allTranslations[npmName])) | 222 | .pipe(map(allTranslations => allTranslations[npmName])) |
221 | .pipe(map(translations => peertubeTranslate(value, translations))) | 223 | .pipe(map(translations => peertubeTranslate(value, translations))) |
222 | .toPromise() | 224 | |
225 | return firstValueFrom(obs) | ||
223 | } | 226 | } |
224 | } | 227 | } |
225 | } | 228 | } |
diff --git a/client/src/app/core/rest/rest-extractor.service.ts b/client/src/app/core/rest/rest-extractor.service.ts index 2a926e68f..29a56ba39 100644 --- a/client/src/app/core/rest/rest-extractor.service.ts +++ b/client/src/app/core/rest/rest-extractor.service.ts | |||
@@ -89,7 +89,7 @@ export class RestExtractor { | |||
89 | errorObj.body = err.error | 89 | errorObj.body = err.error |
90 | } | 90 | } |
91 | 91 | ||
92 | return observableThrowError(errorObj) | 92 | return observableThrowError(() => errorObj) |
93 | } | 93 | } |
94 | 94 | ||
95 | redirectTo404IfNotFound (obj: { status: number }, type: 'video' | 'other', status = [ HttpStatusCode.NOT_FOUND_404 ]) { | 95 | redirectTo404IfNotFound (obj: { status: number }, type: 'video' | 'other', status = [ HttpStatusCode.NOT_FOUND_404 ]) { |
@@ -98,6 +98,6 @@ export class RestExtractor { | |||
98 | this.router.navigate([ '/404' ], { state: { type, obj }, skipLocationChange: true }) | 98 | this.router.navigate([ '/404' ], { state: { type, obj }, skipLocationChange: true }) |
99 | } | 99 | } |
100 | 100 | ||
101 | return observableThrowError(obj) | 101 | return observableThrowError(() => obj) |
102 | } | 102 | } |
103 | } | 103 | } |