Add Ability to close QuickCss
This commit is contained in:
parent
90a1841a97
commit
2568a35aa5
3 changed files with 35 additions and 7 deletions
|
@ -1,13 +1,37 @@
|
|||
!(() => {
|
||||
const { findLazy, Common } = Vencord.Webpack;
|
||||
const { findLazy, Common, onceReady } = Vencord.Webpack;
|
||||
const ModalEscapeHandler = findLazy(m => m.binds?.length === 1 && m.binds[0] === "esc");
|
||||
|
||||
window.VencordMobile = {
|
||||
onBackPress() {
|
||||
// false implies modal closed
|
||||
if (ModalEscapeHandler.action() === false) return;
|
||||
let isSidebarOpen = false;
|
||||
onceReady.then(() => {
|
||||
Common.FluxDispatcher.subscribe("MOBILE_WEB_SIDEBAR_OPEN", () => {
|
||||
isSidebarOpen = true;
|
||||
});
|
||||
Common.FluxDispatcher.subscribe("MOBILE_WEB_SIDEBAR_CLOSE", () => {
|
||||
isSidebarOpen = false;
|
||||
});
|
||||
});
|
||||
|
||||
Common.FluxDispatcher.dispatch({ type: "MOBILE_WEB_SIDEBAR_OPEN" });
|
||||
window.VencordMobile = {
|
||||
// returns true if an action was taken, false if the java side should handle the back press
|
||||
onBackPress() {
|
||||
// false means modal closed (no further action rewuired?)
|
||||
if (ModalEscapeHandler.action() === false) return true;
|
||||
|
||||
// try to close quick css window if open
|
||||
const quickCssWin = window.__VENCORD_MONACO_WIN__?.deref();
|
||||
if (quickCssWin && !quickCssWin.closed) {
|
||||
quickCssWin.close();
|
||||
delete window.__VENCORD_MONACO_WIN__;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isSidebarOpen) {
|
||||
Common.FluxDispatcher.dispatch({ type: "MOBILE_WEB_SIDEBAR_OPEN" });
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue