1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-03 18:28:13 +01:00

[PM-3677] Remove ipcRenderer from desktop utils (#6477)

* [PM-3677] Remove ipcRenderer from utils

* Fix typo
This commit is contained in:
Daniel García 2023-11-09 12:48:18 +01:00 committed by GitHub
parent 929a08339f
commit 7f7700f5f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 10 deletions

View File

@ -8,8 +8,6 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { getCookie } from "../utils";
const BroadcasterSubscriptionId = "AccessibilityCookieComponent";
@Component({
@ -55,7 +53,7 @@ export class AccessibilityCookieComponent {
async checkForCookie() {
this.hCaptchaWindow.close();
const [cookie] = await getCookie("https://www.hcaptcha.com/", "hc_accessibility");
const [cookie] = await ipc.auth.getHcaptchaAccessibilityCookie();
if (cookie) {
this.onCookieSavedSuccess();
} else {

View File

@ -0,0 +1,6 @@
import { ipcRenderer } from "electron";
export default {
getHcaptchaAccessibilityCookie: (): Promise<[string]> =>
ipcRenderer.invoke("getCookie", { url: "https://www.hcaptcha.com/", name: "hc_accessibility" }),
};

View File

@ -60,6 +60,13 @@ export default {
isWindowsStore: isWindowsStore(),
reloadProcess: () => ipcRenderer.send("reload-process"),
openContextMenu: (
menu: {
label?: string;
type?: "normal" | "separator" | "submenu" | "checkbox" | "radio";
}[]
): Promise<number> => ipcRenderer.invoke("openContextMenu", { menu }),
getSystemTheme: (): Promise<ThemeType> => ipcRenderer.invoke("systemTheme"),
onSystemThemeUpdated: (callback: (theme: ThemeType) => void) => {
ipcRenderer.on("systemThemeUpdated", (_event, theme: ThemeType) => callback(theme));

View File

@ -1,4 +1,5 @@
// import { contextBridge } from "electron";
import auth from "./auth/preload";
import platform from "./platform/preload";
/**
@ -13,6 +14,7 @@ import platform from "./platform/preload";
// Each team owns a subspace of the `ipc` global variable in the renderer.
export const ipc = {
auth,
platform,
};

View File

@ -1,5 +1,3 @@
import { ipcRenderer } from "electron";
export type RendererMenuItem = {
label?: string;
type?: "normal" | "separator" | "submenu" | "checkbox" | "radio";
@ -10,7 +8,7 @@ export function invokeMenu(menu: RendererMenuItem[]) {
const menuWithoutClick = menu.map((m) => {
return { label: m.label, type: m.type };
});
ipcRenderer.invoke("openContextMenu", { menu: menuWithoutClick }).then((i: number) => {
ipc.platform.openContextMenu(menuWithoutClick).then((i: number) => {
if (i !== -1) {
menu[i].click();
}
@ -82,7 +80,3 @@ export function cleanUserAgent(userAgent: string): string {
.replace(userAgentItem("Bitwarden", " "), "")
.replace(userAgentItem("Electron", " "), "");
}
export async function getCookie(url: string, name: string): Promise<Electron.Cookie[]> {
return await ipcRenderer.invoke("getCookie", { url: url, name: name });
}