Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Wait CSS variables to be ready

Chocobozzza496da378046
diff --git a/client/src/app/core/theme/theme.service.ts b/client/src/app/core/theme/theme.service.ts
index afabadf18b..6e7e96b901 100644
--- a/client/src/app/core/theme/theme.service.ts
+++ b/client/src/app/core/theme/theme.service.ts
@@ -170,12 +170,33 @@ export class ThemeService {
this.localStorageService.removeItem(UserLocalStorageKeys.LAST_ACTIVE_THEME, false)
}
- setTimeout(() => this.injectColorPalette(), 0)
+ this.injectCoreColorPalette()
this.oldThemeName = currentTheme
}
+ private injectCoreColorPalette (iteration = 0) {
+ if (iteration > 10) {
+ logger.error('Cannot inject core color palette: too many iterations')
+ return
+ }
+
+ if (!this.canInjectColorPalette()) {
+ return setTimeout(() => this.injectCoreColorPalette(iteration + 1))
+ }
+
+ return this.injectColorPalette()
+ }
+
+ private canInjectColorPalette () {
+ const computedStyle = getComputedStyle(document.body)
+
+ return !!computedStyle.getPropertyValue('--fg')
+ }
+
private injectColorPalette () {
+ debugLogger(`Injecting color palette`)
+
const rootStyle = document.body.style
const computedStyle = getComputedStyle(document.body)