diff options
author | Chocobozzz <me@florianbigard.com> | 2019-12-18 15:31:54 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-12-18 15:40:59 +0100 |
commit | ba430d7516bc5b1324b60571ba7594460969b7fb (patch) | |
tree | df5c6952c82f49a94c0a884bbc97d4a0cbd9f867 /client/src/app/core/theme/theme.service.ts | |
parent | 5dfb7c1dec8222b0bbccac5b56ad46da1438747e (diff) | |
download | PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.tar.gz PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.tar.zst PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.zip |
Lazy load static objects
Diffstat (limited to 'client/src/app/core/theme/theme.service.ts')
-rw-r--r-- | client/src/app/core/theme/theme.service.ts | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/client/src/app/core/theme/theme.service.ts b/client/src/app/core/theme/theme.service.ts index 3eebc1acc..2c5873cb3 100644 --- a/client/src/app/core/theme/theme.service.ts +++ b/client/src/app/core/theme/theme.service.ts | |||
@@ -3,7 +3,7 @@ import { AuthService } from '@app/core/auth' | |||
3 | import { ServerService } from '@app/core/server' | 3 | import { ServerService } from '@app/core/server' |
4 | import { environment } from '../../../environments/environment' | 4 | import { environment } from '../../../environments/environment' |
5 | import { PluginService } from '@app/core/plugins/plugin.service' | 5 | import { PluginService } from '@app/core/plugins/plugin.service' |
6 | import { ServerConfigTheme } from '@shared/models' | 6 | import { ServerConfig, ServerConfigTheme } from '@shared/models' |
7 | import { peertubeLocalStorage } from '@app/shared/misc/peertube-web-storage' | 7 | import { peertubeLocalStorage } from '@app/shared/misc/peertube-web-storage' |
8 | import { first } from 'rxjs/operators' | 8 | import { first } from 'rxjs/operators' |
9 | 9 | ||
@@ -20,6 +20,8 @@ export class ThemeService { | |||
20 | private themeFromLocalStorage: ServerConfigTheme | 20 | private themeFromLocalStorage: ServerConfigTheme |
21 | private themeDOMLinksFromLocalStorage: HTMLLinkElement[] = [] | 21 | private themeDOMLinksFromLocalStorage: HTMLLinkElement[] = [] |
22 | 22 | ||
23 | private serverConfig: ServerConfig | ||
24 | |||
23 | constructor ( | 25 | constructor ( |
24 | private auth: AuthService, | 26 | private auth: AuthService, |
25 | private pluginService: PluginService, | 27 | private pluginService: PluginService, |
@@ -30,9 +32,12 @@ export class ThemeService { | |||
30 | // Try to load from local storage first, so we don't have to wait network requests | 32 | // Try to load from local storage first, so we don't have to wait network requests |
31 | this.loadAndSetFromLocalStorage() | 33 | this.loadAndSetFromLocalStorage() |
32 | 34 | ||
33 | this.server.configLoaded | 35 | this.serverConfig = this.server.getTmpConfig() |
34 | .subscribe(() => { | 36 | this.server.getConfig() |
35 | const themes = this.server.getConfig().theme.registered | 37 | .subscribe(config => { |
38 | this.serverConfig = config | ||
39 | |||
40 | const themes = this.serverConfig.theme.registered | ||
36 | 41 | ||
37 | this.removeThemeFromLocalStorageIfNeeded(themes) | 42 | this.removeThemeFromLocalStorageIfNeeded(themes) |
38 | this.injectThemes(themes) | 43 | this.injectThemes(themes) |
@@ -77,7 +82,7 @@ export class ThemeService { | |||
77 | if (theme !== 'instance-default') return theme | 82 | if (theme !== 'instance-default') return theme |
78 | } | 83 | } |
79 | 84 | ||
80 | return this.server.getConfig().theme.default | 85 | return this.serverConfig.theme.default |
81 | } | 86 | } |
82 | 87 | ||
83 | private loadTheme (name: string) { | 88 | private loadTheme (name: string) { |