Skip to content

Commit 10fb0a8

Browse files
committed
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 <[email protected]>
1 parent 123bd5b commit 10fb0a8

File tree

1 file changed

+3
-49
lines changed

1 file changed

+3
-49
lines changed

app/renderer/js/preload.ts

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,61 +7,15 @@ import {ipcRenderer} from "./typed-ipc-renderer.js";
77
contextBridge.exposeInMainWorld("electron_bridge", electron_bridge);
88

99
ipcRenderer.on("logout", () => {
10-
if (bridgeEvents.emit("logout")) {
11-
return;
12-
}
13-
14-
// Create the menu for the below
15-
const dropdown: HTMLElement = document.querySelector(".dropdown-toggle")!;
16-
dropdown.click();
17-
18-
const nodes: NodeListOf<HTMLElement> = document.querySelectorAll(
19-
".dropdown-menu li:last-child a",
20-
);
21-
nodes[nodes.length - 1].click();
10+
bridgeEvents.emit("logout");
2211
});
2312

2413
ipcRenderer.on("show-keyboard-shortcuts", () => {
25-
if (bridgeEvents.emit("show-keyboard-shortcuts")) {
26-
return;
27-
}
28-
29-
// Create the menu for the below
30-
const node: HTMLElement = document.querySelector(
31-
"a[data-overlay-trigger=keyboard-shortcuts]",
32-
)!;
33-
// Additional check
34-
if (node.textContent!.trim().toLowerCase() === "keyboard shortcuts (?)") {
35-
node.click();
36-
} else {
37-
// At least click the dropdown
38-
const dropdown: HTMLElement = document.querySelector(".dropdown-toggle")!;
39-
dropdown.click();
40-
}
14+
bridgeEvents.emit("show-keyboard-shortcuts");
4115
});
4216

4317
ipcRenderer.on("show-notification-settings", () => {
44-
if (bridgeEvents.emit("show-notification-settings")) {
45-
return;
46-
}
47-
48-
// Create the menu for the below
49-
const dropdown: HTMLElement = document.querySelector(".dropdown-toggle")!;
50-
dropdown.click();
51-
52-
const nodes: NodeListOf<HTMLElement> = document.querySelectorAll(
53-
".dropdown-menu li a",
54-
);
55-
nodes[2].click();
56-
57-
const notificationItem: NodeListOf<HTMLElement> = document.querySelectorAll(
58-
".normal-settings-list li div",
59-
);
60-
61-
// Wait until the notification dom element shows up
62-
setTimeout(() => {
63-
notificationItem[2].click();
64-
}, 100);
18+
bridgeEvents.emit("show-notification-settings");
6519
});
6620

6721
window.addEventListener("load", () => {

0 commit comments

Comments
 (0)