mirror of https://github.com/OpenVidu/openvidu.git
ov-components: move theme initialization to ov-videoconference constructor
parent
5c6d8984c2
commit
7071385e22
|
@ -64,6 +64,7 @@ import {
|
||||||
PreJoinDirective,
|
PreJoinDirective,
|
||||||
LeaveButtonDirective
|
LeaveButtonDirective
|
||||||
} from '../../directives/template/internals.directive';
|
} from '../../directives/template/internals.directive';
|
||||||
|
import { OpenViduThemeService } from '../../services/theme/theme.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The **VideoconferenceComponent** is the parent of all OpenVidu components.
|
* The **VideoconferenceComponent** is the parent of all OpenVidu components.
|
||||||
|
@ -710,7 +711,8 @@ export class VideoconferenceComponent implements OnDestroy, AfterViewInit {
|
||||||
private openviduService: OpenViduService,
|
private openviduService: OpenViduService,
|
||||||
private actionService: ActionService,
|
private actionService: ActionService,
|
||||||
private libService: OpenViduComponentsConfigService,
|
private libService: OpenViduComponentsConfigService,
|
||||||
private templateManagerService: TemplateManagerService
|
private templateManagerService: TemplateManagerService,
|
||||||
|
private themeService: OpenViduThemeService
|
||||||
) {
|
) {
|
||||||
this.log = this.loggerSrv.get('VideoconferenceComponent');
|
this.log = this.loggerSrv.get('VideoconferenceComponent');
|
||||||
|
|
||||||
|
@ -726,6 +728,7 @@ export class VideoconferenceComponent implements OnDestroy, AfterViewInit {
|
||||||
error: { hasError: false }
|
error: { hasError: false }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.themeService.initializeTheme();
|
||||||
this.subscribeToVideconferenceDirectives();
|
this.subscribeToVideconferenceDirectives();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,13 @@ export class OpenViduThemeService {
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(DOCUMENT) private document: Document,
|
@Inject(DOCUMENT) private document: Document,
|
||||||
protected storageService: StorageService
|
protected storageService: StorageService
|
||||||
) {
|
) {}
|
||||||
this.initializeTheme();
|
|
||||||
|
initializeTheme(): void {
|
||||||
|
const savedTheme = this.storageService.getTheme();
|
||||||
|
const initialTheme = savedTheme || OpenViduThemeMode.CLASSIC;
|
||||||
|
this.applyTheme(initialTheme);
|
||||||
|
this.currentThemeSubject.next(initialTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -137,13 +142,6 @@ export class OpenViduThemeService {
|
||||||
return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
private initializeTheme(): void {
|
|
||||||
const savedTheme = this.storageService.getTheme();
|
|
||||||
const initialTheme = savedTheme || OpenViduThemeMode.CLASSIC;
|
|
||||||
this.applyTheme(initialTheme);
|
|
||||||
this.currentThemeSubject.next(initialTheme);
|
|
||||||
}
|
|
||||||
|
|
||||||
private applyTheme(theme: OpenViduThemeMode): void {
|
private applyTheme(theme: OpenViduThemeMode): void {
|
||||||
const documentElement = this.document.documentElement;
|
const documentElement = this.document.documentElement;
|
||||||
const currentTheme = this.getCurrentTheme();
|
const currentTheme = this.getCurrentTheme();
|
||||||
|
|
Loading…
Reference in New Issue