1
0
Fork 0

Fix going back

This commit is contained in:
Vendicated 2022-11-25 13:06:46 +01:00
parent 2f35908d0c
commit 3968a53751
No known key found for this signature in database
GPG key ID: EC781ADFB93EFFA3

View file

@ -1,4 +1,5 @@
!(() => {
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 = {
@ -6,7 +7,18 @@ window.VencordMobile = {
// false implies modal closed
if (ModalEscapeHandler.action() === false) return;
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)
}
}
})();