diff options
author | Chocobozzz <me@florianbigard.com> | 2021-08-17 14:42:53 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-08-18 08:35:06 +0200 |
commit | 9df52d660feb722404be00a50f3c8a612bec1c15 (patch) | |
tree | dde52880fa012874d24c60f64eb596b0a789cc8b /client/src/app/core | |
parent | adb8809d43648ea0a64d6845bb39aa3bd0e005a6 (diff) | |
download | PeerTube-9df52d660feb722404be00a50f3c8a612bec1c15.tar.gz PeerTube-9df52d660feb722404be00a50f3c8a612bec1c15.tar.zst PeerTube-9df52d660feb722404be00a50f3c8a612bec1c15.zip |
Migrate client to eslint
Diffstat (limited to 'client/src/app/core')
-rw-r--r-- | client/src/app/core/auth/auth.service.ts | 6 | ||||
-rw-r--r-- | client/src/app/core/hotkeys/hotkeys.component.ts | 6 | ||||
-rw-r--r-- | client/src/app/core/menu/menu.service.ts | 4 | ||||
-rw-r--r-- | client/src/app/core/plugins/hooks.service.ts | 10 | ||||
-rw-r--r-- | client/src/app/core/plugins/plugin.service.ts | 10 | ||||
-rw-r--r-- | client/src/app/core/renderer/markdown.service.ts | 14 | ||||
-rw-r--r-- | client/src/app/core/rest/rest-extractor.service.ts | 26 | ||||
-rw-r--r-- | client/src/app/core/routing/custom-reuse-strategy.ts | 4 | ||||
-rw-r--r-- | client/src/app/core/routing/menu-guard.service.ts | 18 | ||||
-rw-r--r-- | client/src/app/core/routing/meta-guard.service.ts | 2 | ||||
-rw-r--r-- | client/src/app/core/routing/preload-selected-modules-list.ts | 2 | ||||
-rw-r--r-- | client/src/app/core/scoped-tokens/scoped-tokens.service.ts | 7 | ||||
-rw-r--r-- | client/src/app/core/server/server.service.ts | 4 | ||||
-rw-r--r-- | client/src/app/core/theme/theme.service.ts | 4 | ||||
-rw-r--r-- | client/src/app/core/users/user.service.ts | 4 |
15 files changed, 67 insertions, 54 deletions
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index 5da66c981..79239a17a 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts | |||
@@ -48,7 +48,7 @@ export class AuthService { | |||
48 | private hotkeysService: HotkeysService, | 48 | private hotkeysService: HotkeysService, |
49 | private restExtractor: RestExtractor, | 49 | private restExtractor: RestExtractor, |
50 | private router: Router | 50 | private router: Router |
51 | ) { | 51 | ) { |
52 | this.loginChanged = new Subject<AuthStatus>() | 52 | this.loginChanged = new Subject<AuthStatus>() |
53 | this.loginChangedSource = this.loginChanged.asObservable() | 53 | this.loginChangedSource = this.loginChanged.asObservable() |
54 | 54 | ||
@@ -206,7 +206,9 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular | |||
206 | this.refreshingTokenObservable = this.http.post<UserRefreshToken>(AuthService.BASE_TOKEN_URL, body, { headers }) | 206 | this.refreshingTokenObservable = this.http.post<UserRefreshToken>(AuthService.BASE_TOKEN_URL, body, { headers }) |
207 | .pipe( | 207 | .pipe( |
208 | map(res => this.handleRefreshToken(res)), | 208 | map(res => this.handleRefreshToken(res)), |
209 | tap(() => { this.refreshingTokenObservable = null }), | 209 | tap(() => { |
210 | this.refreshingTokenObservable = null | ||
211 | }), | ||
210 | catchError(err => { | 212 | catchError(err => { |
211 | this.refreshingTokenObservable = null | 213 | this.refreshingTokenObservable = null |
212 | 214 | ||
diff --git a/client/src/app/core/hotkeys/hotkeys.component.ts b/client/src/app/core/hotkeys/hotkeys.component.ts index 315e1a25e..60b7516aa 100644 --- a/client/src/app/core/hotkeys/hotkeys.component.ts +++ b/client/src/app/core/hotkeys/hotkeys.component.ts | |||
@@ -3,8 +3,8 @@ import { Subscription } from 'rxjs' | |||
3 | import { Component, Input, OnDestroy, OnInit } from '@angular/core' | 3 | import { Component, Input, OnDestroy, OnInit } from '@angular/core' |
4 | 4 | ||
5 | @Component({ | 5 | @Component({ |
6 | selector : 'my-hotkeys-cheatsheet', | 6 | selector: 'my-hotkeys-cheatsheet', |
7 | templateUrl : './hotkeys.component.html', | 7 | templateUrl: './hotkeys.component.html', |
8 | styleUrls: [ './hotkeys.component.scss' ] | 8 | styleUrls: [ './hotkeys.component.scss' ] |
9 | }) | 9 | }) |
10 | export class CheatSheetComponent implements OnInit, OnDestroy { | 10 | export class CheatSheetComponent implements OnInit, OnDestroy { |
@@ -16,7 +16,7 @@ export class CheatSheetComponent implements OnInit, OnDestroy { | |||
16 | 16 | ||
17 | constructor ( | 17 | constructor ( |
18 | private hotkeysService: HotkeysService | 18 | private hotkeysService: HotkeysService |
19 | ) {} | 19 | ) {} |
20 | 20 | ||
21 | public ngOnInit (): void { | 21 | public ngOnInit (): void { |
22 | this.subscription = this.hotkeysService.cheatSheetToggle.subscribe((isOpen) => { | 22 | this.subscription = this.hotkeysService.cheatSheetToggle.subscribe((isOpen) => { |
diff --git a/client/src/app/core/menu/menu.service.ts b/client/src/app/core/menu/menu.service.ts index 0b8d0191e..f0dc4fcaa 100644 --- a/client/src/app/core/menu/menu.service.ts +++ b/client/src/app/core/menu/menu.service.ts | |||
@@ -25,7 +25,7 @@ export type MenuSection = { | |||
25 | export class MenuService { | 25 | export class MenuService { |
26 | isMenuDisplayed = true | 26 | isMenuDisplayed = true |
27 | isMenuChangedByUser = false | 27 | isMenuChangedByUser = false |
28 | menuWidth = 240 // should be kept equal to $menu-width | 28 | menuWidth = 240 // should be kept equal to $menu-width |
29 | 29 | ||
30 | constructor ( | 30 | constructor ( |
31 | private screenService: ScreenService | 31 | private screenService: ScreenService |
@@ -55,7 +55,7 @@ export class MenuService { | |||
55 | // On touch screens, lock body scroll and display content overlay when memu is opened | 55 | // On touch screens, lock body scroll and display content overlay when memu is opened |
56 | if (this.isMenuDisplayed) { | 56 | if (this.isMenuDisplayed) { |
57 | document.body.classList.add('menu-open') | 57 | document.body.classList.add('menu-open') |
58 | this.screenService.onFingerSwipe('left', () => { this.setMenuDisplay(false) }) | 58 | this.screenService.onFingerSwipe('left', () => this.setMenuDisplay(false)) |
59 | return | 59 | return |
60 | } | 60 | } |
61 | 61 | ||
diff --git a/client/src/app/core/plugins/hooks.service.ts b/client/src/app/core/plugins/hooks.service.ts index ddde198d2..062083fd1 100644 --- a/client/src/app/core/plugins/hooks.service.ts +++ b/client/src/app/core/plugins/hooks.service.ts | |||
@@ -27,9 +27,8 @@ export class HooksService { | |||
27 | }) | 27 | }) |
28 | } | 28 | } |
29 | 29 | ||
30 | wrapObsFun | 30 | wrapObsFun <P, R, H1 extends ClientFilterHookName, H2 extends ClientFilterHookName> |
31 | <P, R, H1 extends ClientFilterHookName, H2 extends ClientFilterHookName> | 31 | (fun: ObservableFunction<P, R>, params: P, scope: PluginClientScope, hookParamName: H1, hookResultName: H2) { |
32 | (fun: ObservableFunction<P, R>, params: P, scope: PluginClientScope, hookParamName: H1, hookResultName: H2) { | ||
33 | return from(this.pluginService.ensurePluginsAreLoaded(scope)) | 32 | return from(this.pluginService.ensurePluginsAreLoaded(scope)) |
34 | .pipe( | 33 | .pipe( |
35 | mergeMap(() => this.wrapObjectWithoutScopeLoad(params, hookParamName)), | 34 | mergeMap(() => this.wrapObjectWithoutScopeLoad(params, hookParamName)), |
@@ -38,9 +37,8 @@ export class HooksService { | |||
38 | ) | 37 | ) |
39 | } | 38 | } |
40 | 39 | ||
41 | async wrapFun | 40 | async wrapFun <P, R, H1 extends ClientFilterHookName, H2 extends ClientFilterHookName> |
42 | <P, R, H1 extends ClientFilterHookName, H2 extends ClientFilterHookName> | 41 | (fun: RawFunction<P, R>, params: P, scope: PluginClientScope, hookParamName: H1, hookResultName: H2) { |
43 | (fun: RawFunction<P, R>, params: P, scope: PluginClientScope, hookParamName: H1, hookResultName: H2) { | ||
44 | await this.pluginService.ensurePluginsAreLoaded(scope) | 42 | await this.pluginService.ensurePluginsAreLoaded(scope) |
45 | 43 | ||
46 | const newParams = await this.wrapObjectWithoutScopeLoad(params, hookParamName) | 44 | const newParams = await this.wrapObjectWithoutScopeLoad(params, hookParamName) |
diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts index 774c03964..89391c2c5 100644 --- a/client/src/app/core/plugins/plugin.service.ts +++ b/client/src/app/core/plugins/plugin.service.ts | |||
@@ -188,7 +188,7 @@ export class PluginService implements ClientHook { | |||
188 | if (!this.authService.isLoggedIn()) return undefined | 188 | if (!this.authService.isLoggedIn()) return undefined |
189 | 189 | ||
190 | const value = this.authService.getRequestHeaderValue() | 190 | const value = this.authService.getRequestHeaderValue() |
191 | return { 'Authorization': value } | 191 | return { Authorization: value } |
192 | }, | 192 | }, |
193 | 193 | ||
194 | notifier: { | 194 | notifier: { |
@@ -198,10 +198,10 @@ export class PluginService implements ClientHook { | |||
198 | }, | 198 | }, |
199 | 199 | ||
200 | showModal: (input: { | 200 | showModal: (input: { |
201 | title: string, | 201 | title: string |
202 | content: string, | 202 | content: string |
203 | close?: boolean, | 203 | close?: boolean |
204 | cancel?: { value: string, action?: () => void }, | 204 | cancel?: { value: string, action?: () => void } |
205 | confirm?: { value: string, action?: () => void } | 205 | confirm?: { value: string, action?: () => void } |
206 | }) => { | 206 | }) => { |
207 | this.zone.run(() => this.customModal.show(input)) | 207 | this.zone.run(() => this.customModal.show(input)) |
diff --git a/client/src/app/core/renderer/markdown.service.ts b/client/src/app/core/renderer/markdown.service.ts index 36258ca98..a81d99534 100644 --- a/client/src/app/core/renderer/markdown.service.ts +++ b/client/src/app/core/renderer/markdown.service.ts | |||
@@ -103,20 +103,20 @@ export class MarkdownService { | |||
103 | const { name, markdown, withEmoji, additionalAllowedTags } = options | 103 | const { name, markdown, withEmoji, additionalAllowedTags } = options |
104 | if (!markdown) return '' | 104 | if (!markdown) return '' |
105 | 105 | ||
106 | const config = this.parsersConfig[ name ] | 106 | const config = this.parsersConfig[name] |
107 | if (!this.markdownParsers[ name ]) { | 107 | if (!this.markdownParsers[name]) { |
108 | this.markdownParsers[ name ] = await this.createMarkdownIt(config) | 108 | this.markdownParsers[name] = await this.createMarkdownIt(config) |
109 | 109 | ||
110 | if (withEmoji) { | 110 | if (withEmoji) { |
111 | if (!this.emojiModule) { | 111 | if (!this.emojiModule) { |
112 | this.emojiModule = (await import('markdown-it-emoji/light')).default | 112 | this.emojiModule = (await import('markdown-it-emoji/light')).default |
113 | } | 113 | } |
114 | 114 | ||
115 | this.markdownParsers[ name ].use(this.emojiModule) | 115 | this.markdownParsers[name].use(this.emojiModule) |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | let html = this.markdownParsers[ name ].render(markdown) | 119 | let html = this.markdownParsers[name].render(markdown) |
120 | html = this.avoidTruncatedTags(html) | 120 | html = this.avoidTruncatedTags(html) |
121 | 121 | ||
122 | if (config.escape) return this.htmlRenderer.toSafeHtml(html, additionalAllowedTags) | 122 | if (config.escape) return this.htmlRenderer.toSafeHtml(html, additionalAllowedTags) |
@@ -156,7 +156,7 @@ export class MarkdownService { | |||
156 | if (relIndex < 0) token.attrPush([ 'rel', 'noopener noreferrer' ]) | 156 | if (relIndex < 0) token.attrPush([ 'rel', 'noopener noreferrer' ]) |
157 | else token.attrs[relIndex][1] = 'noopener noreferrer' | 157 | else token.attrs[relIndex][1] = 'noopener noreferrer' |
158 | 158 | ||
159 | // pass token to default renderer. | 159 | // pass token to default renderer.* |
160 | return defaultRender(tokens, index, options, env, self) | 160 | return defaultRender(tokens, index, options, env, self) |
161 | } | 161 | } |
162 | } | 162 | } |
@@ -164,7 +164,7 @@ export class MarkdownService { | |||
164 | private avoidTruncatedTags (html: string) { | 164 | private avoidTruncatedTags (html: string) { |
165 | return html.replace(/\*\*?([^*]+)$/, '$1') | 165 | return html.replace(/\*\*?([^*]+)$/, '$1') |
166 | .replace(/<a[^>]+>([^<]+)<\/a>\s*...((<\/p>)|(<\/li>)|(<\/strong>))?$/mi, '$1...') | 166 | .replace(/<a[^>]+>([^<]+)<\/a>\s*...((<\/p>)|(<\/li>)|(<\/strong>))?$/mi, '$1...') |
167 | .replace(/\[[^\]]+\]\(([^\)]+)$/m, '$1') | 167 | .replace(/\[[^\]]+\]\(([^)]+)$/m, '$1') |
168 | .replace(/\s?\[[^\]]+\]?[.]{3}<\/p>$/m, '...</p>') | 168 | .replace(/\s?\[[^\]]+\]?[.]{3}<\/p>$/m, '...</p>') |
169 | } | 169 | } |
170 | } | 170 | } |
diff --git a/client/src/app/core/rest/rest-extractor.service.ts b/client/src/app/core/rest/rest-extractor.service.ts index 29a56ba39..dd4a78de5 100644 --- a/client/src/app/core/rest/rest-extractor.service.ts +++ b/client/src/app/core/rest/rest-extractor.service.ts | |||
@@ -13,15 +13,16 @@ export class RestExtractor { | |||
13 | return true | 13 | return true |
14 | } | 14 | } |
15 | 15 | ||
16 | applyToResultListData <T> (result: ResultList<T>, fun: Function, additionalArgs?: any[]): ResultList<T> { | 16 | applyToResultListData <T, A, U> ( |
17 | result: ResultList<T>, | ||
18 | fun: (data: T, ...args: A[]) => U, | ||
19 | additionalArgs: A[] = [] | ||
20 | ): ResultList<U> { | ||
17 | const data: T[] = result.data | 21 | const data: T[] = result.data |
18 | const newData: T[] = [] | ||
19 | |||
20 | data.forEach(d => newData.push(fun.apply(this, [ d ].concat(additionalArgs)))) | ||
21 | 22 | ||
22 | return { | 23 | return { |
23 | total: result.total, | 24 | total: result.total, |
24 | data: newData | 25 | data: data.map(d => fun.apply(this, [ d, ...additionalArgs ])) |
25 | } | 26 | } |
26 | } | 27 | } |
27 | 28 | ||
@@ -29,8 +30,10 @@ export class RestExtractor { | |||
29 | return this.applyToResultListData(result, this.convertDateToHuman, [ fieldsToConvert ]) | 30 | return this.applyToResultListData(result, this.convertDateToHuman, [ fieldsToConvert ]) |
30 | } | 31 | } |
31 | 32 | ||
32 | convertDateToHuman (target: { [ id: string ]: string }, fieldsToConvert: string[]) { | 33 | convertDateToHuman (target: any, fieldsToConvert: string[]) { |
33 | fieldsToConvert.forEach(field => target[field] = dateToHuman(target[field])) | 34 | fieldsToConvert.forEach(field => { |
35 | target[field] = dateToHuman(target[field]) | ||
36 | }) | ||
34 | 37 | ||
35 | return target | 38 | return target |
36 | } | 39 | } |
@@ -46,7 +49,7 @@ export class RestExtractor { | |||
46 | errorMessage = err.error | 49 | errorMessage = err.error |
47 | } else if (err.status !== undefined) { | 50 | } else if (err.status !== undefined) { |
48 | // A server-side error occurred. | 51 | // A server-side error occurred. |
49 | if (err.error && err.error.errors) { | 52 | if (err.error?.errors) { |
50 | const errors = err.error.errors | 53 | const errors = err.error.errors |
51 | const errorsArray: string[] = [] | 54 | const errorsArray: string[] = [] |
52 | 55 | ||
@@ -55,9 +58,10 @@ export class RestExtractor { | |||
55 | }) | 58 | }) |
56 | 59 | ||
57 | errorMessage = errorsArray.join('. ') | 60 | errorMessage = errorsArray.join('. ') |
58 | } else if (err.error && err.error.error) { | 61 | } else if (err.error?.error) { |
59 | errorMessage = err.error.error | 62 | errorMessage = err.error.error |
60 | } else if (err.status === HttpStatusCode.PAYLOAD_TOO_LARGE_413) { | 63 | } else if (err.status === HttpStatusCode.PAYLOAD_TOO_LARGE_413) { |
64 | // eslint-disable-next-line max-len | ||
61 | errorMessage = $localize`Media is too large for the server. Please contact you administrator if you want to increase the limit size.` | 65 | errorMessage = $localize`Media is too large for the server. Please contact you administrator if you want to increase the limit size.` |
62 | } else if (err.status === HttpStatusCode.TOO_MANY_REQUESTS_429) { | 66 | } else if (err.status === HttpStatusCode.TOO_MANY_REQUESTS_429) { |
63 | const secondsLeft = err.headers.get('retry-after') | 67 | const secondsLeft = err.headers.get('retry-after') |
@@ -71,7 +75,7 @@ export class RestExtractor { | |||
71 | errorMessage = $localize`Server error. Please retry later.` | 75 | errorMessage = $localize`Server error. Please retry later.` |
72 | } | 76 | } |
73 | 77 | ||
74 | errorMessage = errorMessage ? errorMessage : 'Unknown error.' | 78 | errorMessage = errorMessage || 'Unknown error.' |
75 | console.error(`Backend returned code ${err.status}, errorMessage is: ${errorMessage}`) | 79 | console.error(`Backend returned code ${err.status}, errorMessage is: ${errorMessage}`) |
76 | } else { | 80 | } else { |
77 | console.error(err) | 81 | console.error(err) |
@@ -93,7 +97,7 @@ export class RestExtractor { | |||
93 | } | 97 | } |
94 | 98 | ||
95 | redirectTo404IfNotFound (obj: { status: number }, type: 'video' | 'other', status = [ HttpStatusCode.NOT_FOUND_404 ]) { | 99 | redirectTo404IfNotFound (obj: { status: number }, type: 'video' | 'other', status = [ HttpStatusCode.NOT_FOUND_404 ]) { |
96 | if (obj && obj.status && status.indexOf(obj.status) !== -1) { | 100 | if (obj?.status && status.includes(obj.status)) { |
97 | // Do not use redirectService to avoid circular dependencies | 101 | // Do not use redirectService to avoid circular dependencies |
98 | this.router.navigate([ '/404' ], { state: { type, obj }, skipLocationChange: true }) | 102 | this.router.navigate([ '/404' ], { state: { type, obj }, skipLocationChange: true }) |
99 | } | 103 | } |
diff --git a/client/src/app/core/routing/custom-reuse-strategy.ts b/client/src/app/core/routing/custom-reuse-strategy.ts index c0f9f04e0..c2510f1df 100644 --- a/client/src/app/core/routing/custom-reuse-strategy.ts +++ b/client/src/app/core/routing/custom-reuse-strategy.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ActivatedRouteSnapshot, DetachedRouteHandle, RouteReuseStrategy } from '@angular/router' | ||
2 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { ActivatedRouteSnapshot, DetachedRouteHandle, RouteReuseStrategy } from '@angular/router' | ||
3 | 3 | ||
4 | @Injectable() | 4 | @Injectable() |
5 | export class CustomReuseStrategy implements RouteReuseStrategy { | 5 | export class CustomReuseStrategy implements RouteReuseStrategy { |
@@ -78,6 +78,6 @@ export class CustomReuseStrategy implements RouteReuseStrategy { | |||
78 | } | 78 | } |
79 | 79 | ||
80 | private isReuseEnabled (route: ActivatedRouteSnapshot) { | 80 | private isReuseEnabled (route: ActivatedRouteSnapshot) { |
81 | return route.data.reuse && route.data.reuse.enabled && route.queryParams[ 'a-state' ] | 81 | return route.data.reuse?.enabled && route.queryParams['a-state'] |
82 | } | 82 | } |
83 | } | 83 | } |
diff --git a/client/src/app/core/routing/menu-guard.service.ts b/client/src/app/core/routing/menu-guard.service.ts index c4e64d434..8c5bbfde9 100644 --- a/client/src/app/core/routing/menu-guard.service.ts +++ b/client/src/app/core/routing/menu-guard.service.ts | |||
@@ -17,33 +17,43 @@ abstract class MenuGuard implements CanActivate, CanDeactivate<any> { | |||
17 | if (!this.screen.isInMobileView() && this.screen.isInMediumView()) { | 17 | if (!this.screen.isInMobileView() && this.screen.isInMediumView()) { |
18 | this.menu.setMenuDisplay(this.display) | 18 | this.menu.setMenuDisplay(this.display) |
19 | } | 19 | } |
20 | |||
20 | return true | 21 | return true |
21 | } | 22 | } |
22 | } | 23 | } |
23 | 24 | ||
24 | @Injectable() | 25 | @Injectable() |
25 | export class OpenMenuGuard extends MenuGuard { | 26 | export class OpenMenuGuard extends MenuGuard { |
26 | constructor (menu: MenuService, screen: ScreenService) { super(menu, screen, true) } | 27 | constructor (menu: MenuService, screen: ScreenService) { |
28 | super(menu, screen, true) | ||
29 | } | ||
27 | } | 30 | } |
28 | 31 | ||
29 | @Injectable() | 32 | @Injectable() |
30 | export class OpenMenuAlwaysGuard extends MenuGuard { | 33 | export class OpenMenuAlwaysGuard extends MenuGuard { |
31 | constructor (menu: MenuService, screen: ScreenService) { super(menu, screen, true) } | 34 | constructor (menu: MenuService, screen: ScreenService) { |
35 | super(menu, screen, true) | ||
36 | } | ||
32 | 37 | ||
33 | canActivate (): boolean { | 38 | canActivate (): boolean { |
34 | this.menu.setMenuDisplay(this.display) | 39 | this.menu.setMenuDisplay(this.display) |
40 | |||
35 | return true | 41 | return true |
36 | } | 42 | } |
37 | } | 43 | } |
38 | 44 | ||
39 | @Injectable() | 45 | @Injectable() |
40 | export class CloseMenuGuard extends MenuGuard { | 46 | export class CloseMenuGuard extends MenuGuard { |
41 | constructor (menu: MenuService, screen: ScreenService) { super(menu, screen, false) } | 47 | constructor (menu: MenuService, screen: ScreenService) { |
48 | super(menu, screen, false) | ||
49 | } | ||
42 | } | 50 | } |
43 | 51 | ||
44 | @Injectable() | 52 | @Injectable() |
45 | export class CloseMenuAlwaysGuard extends MenuGuard { | 53 | export class CloseMenuAlwaysGuard extends MenuGuard { |
46 | constructor (menu: MenuService, screen: ScreenService) { super(menu, screen, false) } | 54 | constructor (menu: MenuService, screen: ScreenService) { |
55 | super(menu, screen, false) | ||
56 | } | ||
47 | 57 | ||
48 | canActivate (): boolean { | 58 | canActivate (): boolean { |
49 | this.menu.setMenuDisplay(this.display) | 59 | this.menu.setMenuDisplay(this.display) |
diff --git a/client/src/app/core/routing/meta-guard.service.ts b/client/src/app/core/routing/meta-guard.service.ts index bedb3450e..851404959 100644 --- a/client/src/app/core/routing/meta-guard.service.ts +++ b/client/src/app/core/routing/meta-guard.service.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, RouterStateSnapshot } from '@angular/router' | 2 | import { ActivatedRouteSnapshot, CanActivate, CanActivateChild } from '@angular/router' |
3 | import { MetaService } from './meta.service' | 3 | import { MetaService } from './meta.service' |
4 | 4 | ||
5 | @Injectable() | 5 | @Injectable() |
diff --git a/client/src/app/core/routing/preload-selected-modules-list.ts b/client/src/app/core/routing/preload-selected-modules-list.ts index b494a40bc..b5c3195b0 100644 --- a/client/src/app/core/routing/preload-selected-modules-list.ts +++ b/client/src/app/core/routing/preload-selected-modules-list.ts | |||
@@ -6,7 +6,7 @@ import { Injectable } from '@angular/core' | |||
6 | @Injectable() | 6 | @Injectable() |
7 | export class PreloadSelectedModulesList implements PreloadingStrategy { | 7 | export class PreloadSelectedModulesList implements PreloadingStrategy { |
8 | 8 | ||
9 | preload (route: Route, load: Function): Observable<any> { | 9 | preload (route: Route, load: () => Observable<any>): Observable<any> { |
10 | if (!route.data || !route.data.preload) return ofObservable(null) | 10 | if (!route.data || !route.data.preload) return ofObservable(null) |
11 | 11 | ||
12 | if (typeof route.data.preload === 'number') { | 12 | if (typeof route.data.preload === 'number') { |
diff --git a/client/src/app/core/scoped-tokens/scoped-tokens.service.ts b/client/src/app/core/scoped-tokens/scoped-tokens.service.ts index 8e3697c31..038e5031c 100644 --- a/client/src/app/core/scoped-tokens/scoped-tokens.service.ts +++ b/client/src/app/core/scoped-tokens/scoped-tokens.service.ts | |||
@@ -1,9 +1,8 @@ | |||
1 | import { Injectable } from '@angular/core' | 1 | import { catchError } from 'rxjs/operators' |
2 | import { HttpClient } from '@angular/common/http' | 2 | import { HttpClient } from '@angular/common/http' |
3 | import { environment } from '../../../environments/environment' | 3 | import { Injectable } from '@angular/core' |
4 | import { AuthService } from '../auth' | ||
5 | import { ScopedToken } from '@shared/models/users/user-scoped-token' | 4 | import { ScopedToken } from '@shared/models/users/user-scoped-token' |
6 | import { catchError } from 'rxjs/operators' | 5 | import { environment } from '../../../environments/environment' |
7 | import { RestExtractor } from '../rest' | 6 | import { RestExtractor } from '../rest' |
8 | 7 | ||
9 | @Injectable() | 8 | @Injectable() |
diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts index 8f041a147..d01942139 100644 --- a/client/src/app/core/server/server.service.ts +++ b/client/src/app/core/server/server.service.ts | |||
@@ -4,7 +4,7 @@ import { HttpClient } from '@angular/common/http' | |||
4 | import { Inject, Injectable, LOCALE_ID } from '@angular/core' | 4 | import { Inject, Injectable, LOCALE_ID } from '@angular/core' |
5 | import { getDevLocale, isOnDevLocale, sortBy } from '@app/helpers' | 5 | import { getDevLocale, isOnDevLocale, sortBy } from '@app/helpers' |
6 | import { getCompleteLocale, isDefaultLocale, peertubeTranslate } from '@shared/core-utils/i18n' | 6 | import { getCompleteLocale, isDefaultLocale, peertubeTranslate } from '@shared/core-utils/i18n' |
7 | import { HTMLServerConfig, SearchTargetType, ServerConfig, ServerStats, VideoConstant } from '@shared/models' | 7 | import { HTMLServerConfig, ServerConfig, ServerStats, VideoConstant } from '@shared/models' |
8 | import { environment } from '../../../environments/environment' | 8 | import { environment } from '../../../environments/environment' |
9 | 9 | ||
10 | @Injectable() | 10 | @Injectable() |
@@ -171,7 +171,7 @@ export class ServerService { | |||
171 | map(({ data, translations }) => { | 171 | map(({ data, translations }) => { |
172 | const hashToPopulate: VideoConstant<T>[] = Object.keys(data) | 172 | const hashToPopulate: VideoConstant<T>[] = Object.keys(data) |
173 | .map(dataKey => { | 173 | .map(dataKey => { |
174 | const label = data[ dataKey ] | 174 | const label = data[dataKey] |
175 | 175 | ||
176 | const id = attributeName === 'languages' | 176 | const id = attributeName === 'languages' |
177 | ? dataKey as T | 177 | ? dataKey as T |
diff --git a/client/src/app/core/theme/theme.service.ts b/client/src/app/core/theme/theme.service.ts index c35548798..c9e6fa700 100644 --- a/client/src/app/core/theme/theme.service.ts +++ b/client/src/app/core/theme/theme.service.ts | |||
@@ -95,8 +95,8 @@ export class ThemeService { | |||
95 | private loadTheme (name: string) { | 95 | private loadTheme (name: string) { |
96 | const links = document.getElementsByTagName('link') | 96 | const links = document.getElementsByTagName('link') |
97 | for (let i = 0; i < links.length; i++) { | 97 | for (let i = 0; i < links.length; i++) { |
98 | const link = links[ i ] | 98 | const link = links[i] |
99 | if (link.getAttribute('rel').indexOf('style') !== -1 && link.getAttribute('title')) { | 99 | if (link.getAttribute('rel').includes('style') && link.getAttribute('title')) { |
100 | link.disabled = link.getAttribute('title') !== name | 100 | link.disabled = link.getAttribute('title') !== name |
101 | } | 101 | } |
102 | } | 102 | } |
diff --git a/client/src/app/core/users/user.service.ts b/client/src/app/core/users/user.service.ts index 47db985e1..a8a774eca 100644 --- a/client/src/app/core/users/user.service.ts +++ b/client/src/app/core/users/user.service.ts | |||
@@ -35,7 +35,7 @@ export class UserService { | |||
35 | private restService: RestService, | 35 | private restService: RestService, |
36 | private localStorageService: LocalStorageService, | 36 | private localStorageService: LocalStorageService, |
37 | private sessionStorageService: SessionStorageService | 37 | private sessionStorageService: SessionStorageService |
38 | ) { } | 38 | ) { } |
39 | 39 | ||
40 | changePassword (currentPassword: string, newPassword: string) { | 40 | changePassword (currentPassword: string, newPassword: string) { |
41 | const url = UserService.BASE_USERS_URL + 'me' | 41 | const url = UserService.BASE_USERS_URL + 'me' |
@@ -266,7 +266,7 @@ export class UserService { | |||
266 | 266 | ||
267 | getUserWithCache (userId: number) { | 267 | getUserWithCache (userId: number) { |
268 | if (!this.userCache[userId]) { | 268 | if (!this.userCache[userId]) { |
269 | this.userCache[ userId ] = this.getUser(userId).pipe(shareReplay()) | 269 | this.userCache[userId] = this.getUser(userId).pipe(shareReplay()) |
270 | } | 270 | } |
271 | 271 | ||
272 | return this.userCache[userId] | 272 | return this.userCache[userId] |