fix case of employee not auto logout on close app

This commit is contained in:
jfrye122
2023-04-21 12:43:33 -04:00
parent 806bf7a576
commit 71d3b43f20

View File

@@ -13,8 +13,15 @@ import { logImEXEvent } from "../../firebase/firebase.analytics";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { setCameraJob, setCameraJobId } from "../../redux/app/app.actions";
import { checkUserSession, emailSignInStart, signOutStart } from "../../redux/user/user.actions";
import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors";
import {
checkUserSession,
emailSignInStart,
signOutStart,
} from "../../redux/user/user.actions";
import {
selectBodyshop,
selectCurrentUser,
} from "../../redux/user/user.selectors";
import { employeeSignOut } from "../../redux/employee/employee.actions";
import { selectCurrentEmployee } from "../../redux/employee/employee.selectors";
@@ -123,13 +130,22 @@ const TimeTicketBrowserStackNavigator = connect(
const appState = useRef(AppState.currentState);
useEffect(() => {
const subscription = AppState.addEventListener("change", (nextAppState) => {
if (
appState.current.match(/inactive|background/) &&
nextAppState === "active"
) {
// console.log("App has come to the foreground");
// console.log("oldAppState", appState.current);
// console.log("nextAppState", nextAppState);
// if ( appState.current.match(/inactive|background/) && nextAppState === "active"
// ) { console.log("App has come to the foreground"); //signOut(); }
// if (appState.current.match(/active/) && nextAppState === "inactive") {
// console.log("App is about to be inactive");
// }
if ( appState.current.match(/active|inactive/) && nextAppState === "background"
) {// console.log("App is about to be background");
signOut();
}
// if ( appState.current.match(/inactive/)) { console.log("App has come to the inactive"); }
// if (appState.current.match(/background/)) { console.log("App has come to the background");}
appState.current = nextAppState;
// console.log("AppState", appState.current);
});