fix case of employee not auto logout on close app
This commit is contained in:
@@ -13,8 +13,15 @@ import { logImEXEvent } from "../../firebase/firebase.analytics";
|
|||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { setCameraJob, setCameraJobId } from "../../redux/app/app.actions";
|
import { setCameraJob, setCameraJobId } from "../../redux/app/app.actions";
|
||||||
import { checkUserSession, emailSignInStart, signOutStart } from "../../redux/user/user.actions";
|
import {
|
||||||
import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors";
|
checkUserSession,
|
||||||
|
emailSignInStart,
|
||||||
|
signOutStart,
|
||||||
|
} from "../../redux/user/user.actions";
|
||||||
|
import {
|
||||||
|
selectBodyshop,
|
||||||
|
selectCurrentUser,
|
||||||
|
} from "../../redux/user/user.selectors";
|
||||||
import { employeeSignOut } from "../../redux/employee/employee.actions";
|
import { employeeSignOut } from "../../redux/employee/employee.actions";
|
||||||
import { selectCurrentEmployee } from "../../redux/employee/employee.selectors";
|
import { selectCurrentEmployee } from "../../redux/employee/employee.selectors";
|
||||||
|
|
||||||
@@ -123,13 +130,22 @@ const TimeTicketBrowserStackNavigator = connect(
|
|||||||
const appState = useRef(AppState.currentState);
|
const appState = useRef(AppState.currentState);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const subscription = AppState.addEventListener("change", (nextAppState) => {
|
const subscription = AppState.addEventListener("change", (nextAppState) => {
|
||||||
if (
|
// console.log("oldAppState", appState.current);
|
||||||
appState.current.match(/inactive|background/) &&
|
// console.log("nextAppState", nextAppState);
|
||||||
nextAppState === "active"
|
// if ( appState.current.match(/inactive|background/) && nextAppState === "active"
|
||||||
) {
|
// ) { console.log("App has come to the foreground"); //signOut(); }
|
||||||
// console.log("App has come to the foreground");
|
// 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();
|
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;
|
appState.current = nextAppState;
|
||||||
// console.log("AppState", appState.current);
|
// console.log("AppState", appState.current);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user