Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync issue while the first tab in "prompted" state. #351

Open
1 task done
saibunneesashaik opened this issue Jun 15, 2023 · 1 comment
Open
1 task done

sync issue while the first tab in "prompted" state. #351

saibunneesashaik opened this issue Jun 15, 2023 · 1 comment
Assignees
Labels
bug A verified and reproducible bug. triage Has not been reviewed yet and should not be worked on.

Comments

@saibunneesashaik
Copy link

What happened?

I opened another tab while the first tab is in "prompted" state and the prompt is showing the "promptBeforeIdle"(1 minute) time in a countdown manner. The second tab is in "active" state now, but the prompt in first tab showing the idle timeout (2 minutes) in countdown rather than the "promptBeforeIdle" time now.

I have implemented these, inspired from the "confirm prompt" in the idle-Timer documentation. This prompt syncs fine when we are opening the new tab when the other tab is in active state.

function SessionTimeout() {
const timeout = 1000 * 60 * 2;
const promptBeforeIdle = 1000 * 60 * 1;
const [remaining, setRemaining] = useState(timeout);
const [isOpen, setOpen] = useState(false);
const onIdle = () => {
setOpen(true);
};
const onPrompt = () => {
setOpen(true);
};
const { getRemainingTime, isPrompted, activate } = useIdleTimer({
onIdle,
stopOnIdle: true,
onPrompt,
syncTimers: 10,
timeout,
crossTab: true,
promptBeforeIdle,
throttle: 500
});

useEffect(() => {
const interval = setInterval(() => {
{
setRemaining(Math.ceil(getRemainingTime() / 1000));
}
}, 1000);
return () => {
clearInterval(interval);
};
});

return (
<>
<SessionTimeoutDialog
isOpen={isOpen}
activate={() => {
activate();
setOpen(false);
}}
remaining={remaining}
/>
</>
);
}

Reproduction Steps

1.open the App and wait for "confirm prompt"
2.After seeing the prompt, load the App in another tab
3.second tab is active now, return to the first tab where we can see the timer is being showing the "timeout" time.
...

Relevant log output

No response

Screenshots or Additional Context

No response

Module Version

5.6.0

What browsers are you seeing the problem on? Select all that apply.

No response

What devices are you seeing the problem on?

No response

Verification

  • I have checked for existing closed issues and discussions.
@saibunneesashaik saibunneesashaik added bug A verified and reproducible bug. triage Has not been reviewed yet and should not be worked on. labels Jun 15, 2023
@ayalade
Copy link

ayalade commented Oct 27, 2024

any update on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A verified and reproducible bug. triage Has not been reviewed yet and should not be worked on.
Projects
None yet
Development

No branches or pull requests

3 participants