1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00

[PM-3680] Remove ipcRenderer from desktop-theming.service (#6478)

This commit is contained in:
Daniel García
2023-10-13 12:20:27 +02:00
committed by GitHub
parent 67fa1e06d0
commit 3dab77ba9e
2 changed files with 8 additions and 6 deletions

View File

@@ -1,5 +1,4 @@
import { Injectable } from "@angular/core";
import { ipcRenderer } from "electron";
import { ThemingService } from "@bitwarden/angular/services/theming/theming.service";
import { ThemeType } from "@bitwarden/common/enums";
@@ -7,12 +6,10 @@ import { ThemeType } from "@bitwarden/common/enums";
@Injectable()
export class DesktopThemingService extends ThemingService {
protected async getSystemTheme(): Promise<ThemeType> {
return await ipcRenderer.invoke("systemTheme");
return await ipc.platform.getSystemTheme();
}
protected monitorSystemThemeChanges(): void {
ipcRenderer.on("systemThemeUpdated", (_event, theme: ThemeType) =>
this.updateSystemTheme(theme)
);
ipc.platform.onSystemThemeUpdated((theme: ThemeType) => this.updateSystemTheme(theme));
}
}

View File

@@ -1,6 +1,6 @@
import { ipcRenderer } from "electron";
import { DeviceType } from "@bitwarden/common/enums/device-type.enum";
import { DeviceType, ThemeType } from "@bitwarden/common/enums";
import { isDev, isWindowsStore } from "../utils";
@@ -12,6 +12,11 @@ export default {
isDev: isDev(),
isWindowsStore: isWindowsStore(),
reloadProcess: () => ipcRenderer.send("reload-process"),
getSystemTheme: (): Promise<ThemeType> => ipcRenderer.invoke("systemTheme"),
onSystemThemeUpdated: (callback: (theme: ThemeType) => void) => {
ipcRenderer.on("systemThemeUpdated", (_event, theme: ThemeType) => callback(theme));
},
};
function deviceType(): DeviceType {