aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/theme/theme.service.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-12-18 15:31:54 +0100
committerChocobozzz <me@florianbigard.com>2019-12-18 15:40:59 +0100
commitba430d7516bc5b1324b60571ba7594460969b7fb (patch)
treedf5c6952c82f49a94c0a884bbc97d4a0cbd9f867 /client/src/app/core/theme/theme.service.ts
parent5dfb7c1dec8222b0bbccac5b56ad46da1438747e (diff)
downloadPeerTube-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.ts15
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'
3import { ServerService } from '@app/core/server' 3import { ServerService } from '@app/core/server'
4import { environment } from '../../../environments/environment' 4import { environment } from '../../../environments/environment'
5import { PluginService } from '@app/core/plugins/plugin.service' 5import { PluginService } from '@app/core/plugins/plugin.service'
6import { ServerConfigTheme } from '@shared/models' 6import { ServerConfig, ServerConfigTheme } from '@shared/models'
7import { peertubeLocalStorage } from '@app/shared/misc/peertube-web-storage' 7import { peertubeLocalStorage } from '@app/shared/misc/peertube-web-storage'
8import { first } from 'rxjs/operators' 8import { 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) {