mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-19 20:51:35 +01:00
[PM-3677] Remove ipcRenderer from desktop utils (#6477)
* [PM-3677] Remove ipcRenderer from utils * Fix typo
This commit is contained in:
parent
929a08339f
commit
7f7700f5f5
@ -8,8 +8,6 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic
|
|||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
|
|
||||||
import { getCookie } from "../utils";
|
|
||||||
|
|
||||||
const BroadcasterSubscriptionId = "AccessibilityCookieComponent";
|
const BroadcasterSubscriptionId = "AccessibilityCookieComponent";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -55,7 +53,7 @@ export class AccessibilityCookieComponent {
|
|||||||
|
|
||||||
async checkForCookie() {
|
async checkForCookie() {
|
||||||
this.hCaptchaWindow.close();
|
this.hCaptchaWindow.close();
|
||||||
const [cookie] = await getCookie("https://www.hcaptcha.com/", "hc_accessibility");
|
const [cookie] = await ipc.auth.getHcaptchaAccessibilityCookie();
|
||||||
if (cookie) {
|
if (cookie) {
|
||||||
this.onCookieSavedSuccess();
|
this.onCookieSavedSuccess();
|
||||||
} else {
|
} else {
|
||||||
|
6
apps/desktop/src/auth/preload.ts
Normal file
6
apps/desktop/src/auth/preload.ts
Normal 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" }),
|
||||||
|
};
|
@ -60,6 +60,13 @@ export default {
|
|||||||
isWindowsStore: isWindowsStore(),
|
isWindowsStore: isWindowsStore(),
|
||||||
reloadProcess: () => ipcRenderer.send("reload-process"),
|
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"),
|
getSystemTheme: (): Promise<ThemeType> => ipcRenderer.invoke("systemTheme"),
|
||||||
onSystemThemeUpdated: (callback: (theme: ThemeType) => void) => {
|
onSystemThemeUpdated: (callback: (theme: ThemeType) => void) => {
|
||||||
ipcRenderer.on("systemThemeUpdated", (_event, theme: ThemeType) => callback(theme));
|
ipcRenderer.on("systemThemeUpdated", (_event, theme: ThemeType) => callback(theme));
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// import { contextBridge } from "electron";
|
// import { contextBridge } from "electron";
|
||||||
|
import auth from "./auth/preload";
|
||||||
import platform from "./platform/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.
|
// Each team owns a subspace of the `ipc` global variable in the renderer.
|
||||||
export const ipc = {
|
export const ipc = {
|
||||||
|
auth,
|
||||||
platform,
|
platform,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import { ipcRenderer } from "electron";
|
|
||||||
|
|
||||||
export type RendererMenuItem = {
|
export type RendererMenuItem = {
|
||||||
label?: string;
|
label?: string;
|
||||||
type?: "normal" | "separator" | "submenu" | "checkbox" | "radio";
|
type?: "normal" | "separator" | "submenu" | "checkbox" | "radio";
|
||||||
@ -10,7 +8,7 @@ export function invokeMenu(menu: RendererMenuItem[]) {
|
|||||||
const menuWithoutClick = menu.map((m) => {
|
const menuWithoutClick = menu.map((m) => {
|
||||||
return { label: m.label, type: m.type };
|
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) {
|
if (i !== -1) {
|
||||||
menu[i].click();
|
menu[i].click();
|
||||||
}
|
}
|
||||||
@ -82,7 +80,3 @@ export function cleanUserAgent(userAgent: string): string {
|
|||||||
.replace(userAgentItem("Bitwarden", " "), "")
|
.replace(userAgentItem("Bitwarden", " "), "")
|
||||||
.replace(userAgentItem("Electron", " "), "");
|
.replace(userAgentItem("Electron", " "), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getCookie(url: string, name: string): Promise<Electron.Cookie[]> {
|
|
||||||
return await ipcRenderer.invoke("getCookie", { url: url, name: name });
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user