Closed blacknight9 closed 1 year ago
It will be triggered due to user inactivity, can you post the values you are passing for SessionConfig
eg:
final sessionConfig = SessionConfig(
invalidateSessionForAppLostFocus: const Duration(seconds: 15),
invalidateSessionForUserInactivity: const Duration(seconds: 30));
I copied your example to my. Project, and i used snackbar for test, and it's only triggered when there is activity, when i stop nothing happens, i can share a video if you want
@override
Widget build(BuildContext context) {
final sessionConfig = SessionConfig(
invalidateSessionForAppLostFocus: const Duration(seconds: 15),
invalidateSessionForUserInactivity: const Duration(seconds: 5));
sessionConfig.stream.listen((SessionTimeoutState timeoutEvent) {
if (timeoutEvent == SessionTimeoutState.userInactivityTimeout) {
log(timeoutEvent.toString(),name: 'timeoutEvent == SessionTimeoutState.userInactivityTimeout');
// handle user inactive timeout
// Navigator.of(context).pushNamed("/auth");
Get.snackbar('userInactivityTimeout', 'userInactivityTimeout');
} else if (timeoutEvent == SessionTimeoutState.appFocusTimeout) {
Get.to(()=>ProfilePageScreen());
// handle user app lost focus timeout
// Navigator.of(context).pushNamed("/auth");
Get.snackbar('appFocusTimeout', 'appFocusTimeout');
}
});
return SessionTimeoutManager(
sessionConfig: sessionConfig,
child: GetMaterialApp()..
Can you increase invalidateSessionForUserInactivity
to a higher value, say 30 seconds.
i can share a video if you want
Yes that would be helpful
Can you increase
invalidateSessionForUserInactivity
to a higher value, say 30 seconds.i can share a video if you want
Yes that would be helpful
the 5 sec is just for test, this shouldn't effect how the functionality works ,
here is the video, notice the beginning and the end is where no activity was going and nothing triggered until i start moving around (still set to 5 seconds)
https://youtu.be/YqNxlrSDZ4Y give the video a minute to finish processing on Ytb
Got it, it appears that timer is starting only after the first touch right?
Yes, and then it's suspended. And again triggered after activity.
But that's not it, technically it should not be triggerd since user is active.
Thank you for you prompt reply
But that's not it, technically it should not be triggerd since user is active.
Yes that shouldn't be happening, can you post minimum code required to reproduce this bug
I got it. Default value of userActivityDebounceDuration
is 10 seconds which means it records only one user event for 10 seconds (to prevent memory leaks because of setTimeout objects), you can change this value to a lower number like 1 or 2 seconds. You can pass it as a parameter to SessionTimeoutManager
Regarding the timer starting only after the initial touch event, let me know if its an issue for your use-case
But that's not it, technically it should not be triggerd since user is active.
Yes that shouldn't be happening, can you post minimum code required to reproduce this bug
check this https://github.com/blacknight9/local_session_timeout_test
Regarding the timer starting only after the initial touch event, let me know if its an issue for your use-case
yes ,, the issues i'm facing:
1- counter doesn't start until initial touch 2- the function for no activity is triggered when user is active
Did you try this, this should solve second point
I got it. Default value of userActivityDebounceDuration is 10 seconds which means it records only one user event for 10 seconds (to prevent memory leaks because of setTimeout objects), you can change this value to a lower number like 1 or 2 seconds. You can pass it as a parameter to SessionTimeoutManager
For 1st point,SessionTimeoutManager
takes an optional parameter sessionStateStream
, you can pass SessionState.startListening
event to that stream as soon as your app renders (you can refer example app for SessionState usage)
sessionStateStream.add(SessionState.startListening);
how to use this ?
because when i add this argument to SessionTimeoutManager i get error
type 'SessionState' is not a subtype of type 'Stream<SessionState>?'
Did you try this, this should solve second point
I got it. Default value of userActivityDebounceDuration is 10 seconds which means it records only one user event for 10 seconds (to prevent memory leaks because of setTimeout objects), you can change this value to a lower number like 1 or 2 seconds. You can pass it as a parameter to SessionTimeoutManager
yes, thank you, this works
because when i add this argument to SessionTimeoutManager i get error
The parameter itself is a stream, you need to pass SessionState.startListening to that stream. Refer the example app, let me know if you need any help
hey,
i installed your package and in my test, it looks like this function keep triggering when i'm active no the way around !