1
0
Fork 0

Fix: back button closes modals, otherwise opens drawer

This commit is contained in:
Vendicated 2022-12-11 08:36:48 +01:00
parent 4a2590b4ba
commit 4ae8b960d6
No known key found for this signature in database
GPG key ID: EC781ADFB93EFFA3

View file

@ -1,24 +1,13 @@
!(() => { !(() => {
const Bruh = Vencord.Util.lazyWebpack(m => m.emitter?._events?.SCROLLTO_PRESENT) const { findLazy, Common } = Vencord.Webpack;
const ModalEscapeHandler = Vencord.Util.lazyWebpack(m => m.binds?.[0] === "esc" && m.binds.length === 1); const ModalEscapeHandler = findLazy(m => m.binds?.length === 1 && m.binds[0] === "esc");
const EscapeHandler = Vencord.Util.lazyWebpack(m => m.binds?.[0] === "esc" && m.binds[1] === "shift+pagedown");
window.VencordMobile = {
onBackPress() {
// false implies modal closed
if (ModalEscapeHandler.action() === false) return;
let hadEffect = true; window.VencordMobile = {
const onScroll = () => hadEffect = false; onBackPress() {
Bruh.subscribe("SCROLLTO_PRESENT", onScroll); // false implies modal closed
// DISCORD IS BRAINDEAD AND ALWAYS RETURNS FALSE so we need to do the hack where we check if the if (ModalEscapeHandler.action() === false) return;
// event was dispatched (aka end was reached)
EscapeHandler.action({target:document.activeElement}); Common.FluxDispatcher.dispatch({ type: "MOBILE_WEB_SIDEBAR_OPEN" });
setTimeout(() => { }
Bruh.unsubscribe("SCROLLTO_PRESENT", onScroll); };
if (!hadEffect) { })();
VencordMobileNative.goBack();
}
}, 50)
}
}
})();