Skip to content

Commit 4ae8b96

Browse files
committed
Fix: back button closes modals, otherwise opens drawer
1 parent 4a2590b commit 4ae8b96

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed
Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
11
!(() => {
2-
const Bruh = Vencord.Util.lazyWebpack(m => m.emitter?._events?.SCROLLTO_PRESENT)
3-
const ModalEscapeHandler = Vencord.Util.lazyWebpack(m => m.binds?.[0] === "esc" && m.binds.length === 1);
4-
const EscapeHandler = Vencord.Util.lazyWebpack(m => m.binds?.[0] === "esc" && m.binds[1] === "shift+pagedown");
5-
window.VencordMobile = {
6-
onBackPress() {
7-
// false implies modal closed
8-
if (ModalEscapeHandler.action() === false) return;
2+
const { findLazy, Common } = Vencord.Webpack;
3+
const ModalEscapeHandler = findLazy(m => m.binds?.length === 1 && m.binds[0] === "esc");
94

10-
let hadEffect = true;
11-
const onScroll = () => hadEffect = false;
12-
Bruh.subscribe("SCROLLTO_PRESENT", onScroll);
13-
// DISCORD IS BRAINDEAD AND ALWAYS RETURNS FALSE so we need to do the hack where we check if the
14-
// event was dispatched (aka end was reached)
15-
EscapeHandler.action({target:document.activeElement});
16-
setTimeout(() => {
17-
Bruh.unsubscribe("SCROLLTO_PRESENT", onScroll);
18-
if (!hadEffect) {
19-
VencordMobileNative.goBack();
20-
}
21-
}, 50)
22-
}
23-
}
24-
})();
5+
window.VencordMobile = {
6+
onBackPress() {
7+
// false implies modal closed
8+
if (ModalEscapeHandler.action() === false) return;
9+
10+
Common.FluxDispatcher.dispatch({ type: "MOBILE_WEB_SIDEBAR_OPEN" });
11+
}
12+
};
13+
})();

0 commit comments

Comments
 (0)