Fix: back button closes modals, otherwise opens drawer
This commit is contained in:
parent
4a2590b4ba
commit
4ae8b960d6
1 changed files with 11 additions and 22 deletions
|
@ -1,24 +1,13 @@
|
|||
!(() => {
|
||||
const Bruh = Vencord.Util.lazyWebpack(m => m.emitter?._events?.SCROLLTO_PRESENT)
|
||||
const ModalEscapeHandler = Vencord.Util.lazyWebpack(m => m.binds?.[0] === "esc" && m.binds.length === 1);
|
||||
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;
|
||||
const { findLazy, Common } = Vencord.Webpack;
|
||||
const ModalEscapeHandler = findLazy(m => m.binds?.length === 1 && m.binds[0] === "esc");
|
||||
|
||||
let hadEffect = true;
|
||||
const onScroll = () => hadEffect = false;
|
||||
Bruh.subscribe("SCROLLTO_PRESENT", onScroll);
|
||||
// DISCORD IS BRAINDEAD AND ALWAYS RETURNS FALSE so we need to do the hack where we check if the
|
||||
// event was dispatched (aka end was reached)
|
||||
EscapeHandler.action({target:document.activeElement});
|
||||
setTimeout(() => {
|
||||
Bruh.unsubscribe("SCROLLTO_PRESENT", onScroll);
|
||||
if (!hadEffect) {
|
||||
VencordMobileNative.goBack();
|
||||
}
|
||||
}, 50)
|
||||
}
|
||||
}
|
||||
})();
|
||||
window.VencordMobile = {
|
||||
onBackPress() {
|
||||
// false implies modal closed
|
||||
if (ModalEscapeHandler.action() === false) return;
|
||||
|
||||
Common.FluxDispatcher.dispatch({ type: "MOBILE_WEB_SIDEBAR_OPEN" });
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
|
Loading…
Reference in a new issue