Skip to content

FIX: prevent navigation block when device time is adjusted backward #994

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

joaovvrodrigues
Copy link

@joaovvrodrigues joaovvrodrigues commented Mar 31, 2025

Description

This PR fixes an issue where Modular’s navigation system could prevent page transitions if the device's date/time was adjusted backward.

Context

In some systems, the device’s date and time can be automatically synchronized via an NTP server, an API endpoint, or external hardware. If the device clock was ahead and then corrected to an earlier time, the time difference calculation (currentTime.difference(_lastClick)) would result in a negative value. Since the original code blocked navigation when this difference was less than 500ms, this could permanently prevent navigation.

Solution

Now, the time difference calculation ensures it never goes negative:

final diffTimes = currentTime.isBefore(_lastClick) ? 0 : currentTime.difference(_lastClick).inMilliseconds;

If currentTime is earlier than _lastClick, the difference is considered 0, allowing navigation to proceed as expected.

Breaking Change

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant