Skip to content

Commit

Permalink
fix: merge develop and adjust ACTIVITY_TIMEOUT
Browse files Browse the repository at this point in the history
  • Loading branch information
jimcase committed Apr 30, 2024
1 parent 28c34bf commit aa9b25d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/ui/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "@ionic/react";
import { StatusBar, Style } from "@capacitor/status-bar";
import { ScreenOrientation } from "@capacitor/screen-orientation";
import { RoutePath, Routes } from "../routes";
import { Routes } from "../routes";
import "./styles/ionic.scss";
import "./styles/style.scss";
import "./App.scss";
Expand All @@ -25,10 +25,10 @@ import { OperationType } from "./globals/types";
import { IncomingRequest } from "./pages/IncomingRequest";
import { Settings } from "./pages/Settings";
import { SetUserName } from "./components/SetUserName";
import { PublicRoutes, TabsRoutePath } from "../routes/paths";
import { TabsRoutePath } from "../routes/paths";
import { MobileHeaderPreview } from "./components/MobileHeaderPreview";
import { CustomToast } from "./components/CustomToast/CustomToast";
import { LockModal } from "./components/LockModal/LockModal";
import { LockModal } from "./components/LockModal";

setupIonicReact();

Expand Down
17 changes: 4 additions & 13 deletions src/ui/components/AppWrapper/AppWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ const AppWrapper = (props: { children: ReactNode }) => {
const authentication = useAppSelector(getAuthentication);
const [agentInitErr, setAgentInitErr] = useState(false);

const ACTIVITY_TIMEOUT = 5000;
const ACTIVITY_TIMEOUT = 60000;
let timer: NodeJS.Timeout;
let timeoutDuration = ACTIVITY_TIMEOUT;
const timeoutDuration = ACTIVITY_TIMEOUT;

useEffect(() => {
const handleActivity = () => {
Expand All @@ -124,16 +124,8 @@ const AppWrapper = (props: { children: ReactNode }) => {
}, timeoutDuration);
};

const handleAppStateChange = ({ isActive }: { isActive: boolean }) => {
if (isActive) {
timeoutDuration = ACTIVITY_TIMEOUT;
} else {
timeoutDuration = ACTIVITY_TIMEOUT / 2;
}
handleActivity();
};

App.addListener("appStateChange", handleAppStateChange);
// TODO: detect appStateChange in android and ios to reduce the ACTIVITY_TIMEOUT
// App.addListener("appStateChange", handleAppStateChange);
window.addEventListener("load", handleActivity);
document.addEventListener("mousemove", handleActivity);
document.addEventListener("touchstart", handleActivity);
Expand All @@ -144,7 +136,6 @@ const AppWrapper = (props: { children: ReactNode }) => {
document.addEventListener("scroll", handleActivity);

return () => {
App.removeAllListeners();
window.removeEventListener("load", handleActivity);
document.removeEventListener("mousemove", handleActivity);
document.removeEventListener("touchstart", handleActivity);
Expand Down

0 comments on commit aa9b25d

Please sign in to comment.