Skip to content

Commit

Permalink
[webpack] fix drawer not closed when back button is pressed
Browse files Browse the repository at this point in the history
  • Loading branch information
DerGoogler committed Sep 14, 2024
1 parent 7846efc commit 5e26f65
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"@types/fs-extra": "^11.0.4",
"@types/gh-pages": "^6.1.0",
"@types/ini": "^4.1.0",
"@types/node": "^18.0.6",
"@types/node": "^18.19.50",
"@types/object-assign": "^4.0.30",
"@types/react": "^18.2.67",
"@types/react-dom": "^18.0.2",
Expand Down
23 changes: 22 additions & 1 deletion src/activitys/MainActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { LogcatActivity } from "./LogcatActivity";
import UnverifiedHostActivity from "./UnverifiedHostActivity";
import { LandingActivity } from "./LandingActivity";
import { ModulesQueue } from "@Components/ModulesQueue";
import { useConfirm } from "material-ui-confirm";

const getLocation = () => {
if (window.location !== window.parent.location) {
Expand Down Expand Up @@ -71,6 +72,7 @@ const MainActivity = (): JSX.Element => {
const { theme } = useTheme();
const { modFS } = useModFS();
const InitialActivity = useCheckRoot();
const confirm = useConfirm();

const [isSplitterOpen, setIsSplitterOpen] = useState(false);

Expand Down Expand Up @@ -108,7 +110,6 @@ const MainActivity = (): JSX.Element => {
splitter: {
show: () => showSplitter(),
hide: () => hideSplitter(),
state: isSplitterOpen,
},
};

Expand Down Expand Up @@ -313,6 +314,26 @@ const MainActivity = (): JSX.Element => {
return (
<ModulesQueue context={pushContext as any}>
<Page
onDeviceBackButton={(e) => {
if (isSplitterOpen) {
hideSplitter();
} else {
confirm({
title: strings("exit_app"),
description: strings("exit_app_desc"),
confirmationText: strings("yes"),
cancellationText: strings("no"),
})
.then(() => {
if (typeof e.callParentHandler === "function") {
e.callParentHandler();
} else {
navigator.app.exitApp();
}
})
.catch(() => {});
}
}}
onInit={() => {
const mmrlFolder = new SuFile(modFS("MMRLFOL"));

Expand Down
17 changes: 3 additions & 14 deletions src/activitys/MainApplication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,9 @@ const MainApplication = () => {
const handleBackEvent = React.useCallback(
(e: any) => {
if (index === 0) {
confirm({
title: strings("exit_app"),
description: strings("exit_app_desc"),
confirmationText: strings("yes"),
cancellationText: strings("no"),
})
.then(() => {
if (typeof e.callParentHandler === "function") {
e.callParentHandler();
} else {
navigator.app.exitApp();
}
})
.catch(() => {});
if (typeof e.callParentHandler === "function") {
e.callParentHandler();
}
} else {
setIndex(0);
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/module/DeviceModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,12 @@ const DeviceModule = React.memo<Props>((props) => {
if (remove.exist()) {
if (remove.delete()) {
setIsSwitchDisabled(false);
log.d(`${module} has been recovered`);
log.d(`${id} has been recovered`);
} else {
log.e(`Failed to restore ${module}`);
log.e(`Failed to restore ${id}`);
}
} else {
log.e(`This remove file don't exists for ${module}`);
log.e(`This remove file don't exists for ${id}`);
}
}}
disableElevation
Expand Down
1 change: 0 additions & 1 deletion src/hooks/useActivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export interface ActivityContext {
readonly splitter: {
readonly show: () => void;
readonly hide: () => void;
readonly state: boolean;
};
}

Expand Down

0 comments on commit 5e26f65

Please sign in to comment.