mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 17:23:37 +00:00
[PM-5539] Migrate ThemingService (#8219)
* Update ThemingService * Finish ThemingService * Lint * More Tests & Docs * Refactor to ThemeStateService * Rename File * Fix Import * Remove `type` added to imports * Update InitServices * Fix Test * Remove Unreferenced Code * Remove Unneeded Null Check * Add Ticket Link * Add Back THEMING_DISK * Fix Desktop * Create SYSTEM_THEME_OBSERVABLE * Fix Browser Injection * Update Desktop Manual Access * Fix Default Theme * Update Test
This commit is contained in:
@@ -3,13 +3,13 @@ import { DomSanitizer } from "@angular/platform-browser";
|
||||
import { ToastrService } from "ngx-toastr";
|
||||
|
||||
import { UnauthGuard as BaseUnauthGuardService } from "@bitwarden/angular/auth/guards";
|
||||
import { ThemingService } from "@bitwarden/angular/platform/services/theming/theming.service";
|
||||
import { AbstractThemingService } from "@bitwarden/angular/platform/services/theming/theming.service.abstraction";
|
||||
import { AngularThemingService } from "@bitwarden/angular/platform/services/theming/angular-theming.service";
|
||||
import {
|
||||
MEMORY_STORAGE,
|
||||
SECURE_STORAGE,
|
||||
OBSERVABLE_DISK_STORAGE,
|
||||
OBSERVABLE_MEMORY_STORAGE,
|
||||
SYSTEM_THEME_OBSERVABLE,
|
||||
} from "@bitwarden/angular/services/injection-tokens";
|
||||
import { JslibServicesModule } from "@bitwarden/angular/services/jslib-services.module";
|
||||
import {
|
||||
@@ -488,11 +488,8 @@ function getBgService<T>(service: keyof MainBackground) {
|
||||
deps: [StateServiceAbstraction],
|
||||
},
|
||||
{
|
||||
provide: AbstractThemingService,
|
||||
useFactory: (
|
||||
stateService: StateServiceAbstraction,
|
||||
platformUtilsService: PlatformUtilsService,
|
||||
) => {
|
||||
provide: SYSTEM_THEME_OBSERVABLE,
|
||||
useFactory: (platformUtilsService: PlatformUtilsService) => {
|
||||
// Safari doesn't properly handle the (prefers-color-scheme) media query in the popup window, it always returns light.
|
||||
// In Safari, we have to use the background page instead, which comes with limitations like not dynamically changing the extension theme when the system theme is changed.
|
||||
let windowContext = window;
|
||||
@@ -501,9 +498,9 @@ function getBgService<T>(service: keyof MainBackground) {
|
||||
windowContext = backgroundWindow;
|
||||
}
|
||||
|
||||
return new ThemingService(stateService, windowContext, document);
|
||||
return AngularThemingService.createSystemThemeFromWindow(windowContext);
|
||||
},
|
||||
deps: [StateServiceAbstraction, PlatformUtilsService],
|
||||
deps: [PlatformUtilsService],
|
||||
},
|
||||
{
|
||||
provide: ConfigService,
|
||||
|
||||
Reference in New Issue
Block a user