From 3968a537515e42b0a4ca814394a843c6c1a1f462 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 25 Nov 2022 13:06:46 +0100 Subject: [PATCH] Fix going back --- app/src/main/res/raw/vencord_mobile.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/res/raw/vencord_mobile.js b/app/src/main/res/raw/vencord_mobile.js index d43c572..58380b3 100644 --- a/app/src/main/res/raw/vencord_mobile.js +++ b/app/src/main/res/raw/vencord_mobile.js @@ -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) } } })(); \ No newline at end of file