mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-10-23 03:31:56 +00:00
preload: Drop compatibility code for Zulip Server < 4.0.
The server was updated in bfd9999cf874e506592fda254dfe0fe06b5b2738 (4.0-rc1~2192) to expose a proper API for this functionality, so we don’t need to trigger fake click events to access it. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Anders Kaseorg
parent
123bd5b2c0
commit
10fb0a82f9
@@ -7,61 +7,15 @@ import {ipcRenderer} from "./typed-ipc-renderer.js";
|
||||
contextBridge.exposeInMainWorld("electron_bridge", electron_bridge);
|
||||
|
||||
ipcRenderer.on("logout", () => {
|
||||
if (bridgeEvents.emit("logout")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the menu for the below
|
||||
const dropdown: HTMLElement = document.querySelector(".dropdown-toggle")!;
|
||||
dropdown.click();
|
||||
|
||||
const nodes: NodeListOf<HTMLElement> = document.querySelectorAll(
|
||||
".dropdown-menu li:last-child a",
|
||||
);
|
||||
nodes[nodes.length - 1].click();
|
||||
bridgeEvents.emit("logout");
|
||||
});
|
||||
|
||||
ipcRenderer.on("show-keyboard-shortcuts", () => {
|
||||
if (bridgeEvents.emit("show-keyboard-shortcuts")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the menu for the below
|
||||
const node: HTMLElement = document.querySelector(
|
||||
"a[data-overlay-trigger=keyboard-shortcuts]",
|
||||
)!;
|
||||
// Additional check
|
||||
if (node.textContent!.trim().toLowerCase() === "keyboard shortcuts (?)") {
|
||||
node.click();
|
||||
} else {
|
||||
// At least click the dropdown
|
||||
const dropdown: HTMLElement = document.querySelector(".dropdown-toggle")!;
|
||||
dropdown.click();
|
||||
}
|
||||
bridgeEvents.emit("show-keyboard-shortcuts");
|
||||
});
|
||||
|
||||
ipcRenderer.on("show-notification-settings", () => {
|
||||
if (bridgeEvents.emit("show-notification-settings")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the menu for the below
|
||||
const dropdown: HTMLElement = document.querySelector(".dropdown-toggle")!;
|
||||
dropdown.click();
|
||||
|
||||
const nodes: NodeListOf<HTMLElement> = document.querySelectorAll(
|
||||
".dropdown-menu li a",
|
||||
);
|
||||
nodes[2].click();
|
||||
|
||||
const notificationItem: NodeListOf<HTMLElement> = document.querySelectorAll(
|
||||
".normal-settings-list li div",
|
||||
);
|
||||
|
||||
// Wait until the notification dom element shows up
|
||||
setTimeout(() => {
|
||||
notificationItem[2].click();
|
||||
}, 100);
|
||||
bridgeEvents.emit("show-notification-settings");
|
||||
});
|
||||
|
||||
window.addEventListener("load", () => {
|
||||
|
Reference in New Issue
Block a user