TP-35796 | changed activity time window to 10

This commit is contained in:
Varnit Goyal
2023-08-04 07:43:35 +05:30
parent b12d0357c5
commit e00d33cf0b
2 changed files with 5 additions and 9 deletions

View File

@@ -74,7 +74,6 @@ public class MainApplication extends Application implements ReactApplication {
if (BuildConfig.DEBUG) {
e.printStackTrace();
}
}
}
/**

View File

@@ -53,7 +53,6 @@ const TrackingComponent: React.FC<ITrackingComponent> = ({ children }) => {
const dispatch = useAppDispatch();
const appState = useRef(AppState.currentState);
const user = useAppSelector((state) => state.user);
const isActive = useAppSelector((state) => state?.user?.user?.isActive);
const {
referenceId,
@@ -132,6 +131,10 @@ const TrackingComponent: React.FC<ITrackingComponent> = ({ children }) => {
};
const handleUpdateActiveness = async () => {
if (AppState.currentState === AppStates.ACTIVE) {
await setItem(StorageKeys.IS_USER_ACTIVE, 'true');
return;
}
const foregroundTimestamp = await getItem(StorageKeys.APP_FOREGROUND_TIMESTAMP);
const backgroundTimestamp = await getItem(StorageKeys.APP_BACKGROUND_TIMESTAMP);
const foregroundTime = dayjs(foregroundTimestamp);
@@ -145,13 +148,7 @@ const TrackingComponent: React.FC<ITrackingComponent> = ({ children }) => {
const isForegroundTimeWithInRange =
diffBetweenCurrentTimeAndForegroundTime <= ACTIVITY_TIME_WINDOW;
const isForegroundTimeAfterBackground = dayjs(foregroundTimestamp).isAfter(backgroundTimestamp);
console.log({
diffBetweenBackgroundAndForegroundTime,
diffBetweenCurrentTimeAndForegroundTime,
isForegroundTimeWithInRange,
isForegroundTimeAfterBackground,
dayjs: dayjs().toString(),
});
if (isForegroundTimeWithInRange) {
if (
isForegroundTimeAfterBackground ||