-
Notifications
You must be signed in to change notification settings - Fork 0
Implement NTP-based time synchronization #33
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughIntroduces ServerTimeService for NTP-based time sync, initializes it during app startup, and updates time usage: TimezoneService now derives current time from ServerTimeService. Event screens switch past-event checks from direct DateTime.now() comparisons to hasEnded. Adds ntp dependency. No public API signatures changed. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App as main.dart
participant TZ as TimezoneService
participant ST as ServerTimeService
participant NTP as NTP Server
rect rgba(221,238,255,0.5)
note over App: App startup
App->>TZ: initialize timezones
App->>ST: initialize()
activate ST
ST->>NTP: fetch current time (timeout 5s)
alt success
NTP-->>ST: ntpTime
ST-->>ST: compute offset (ntp - device)
else failure
ST-->>ST: set zero offset
end
deactivate ST
App->>App: continue startup
end
sequenceDiagram
autonumber
participant UI as Event/Timezone callers
participant TZ as TimezoneService
participant ST as ServerTimeService
rect rgba(232,252,244,0.6)
note over UI: Need current Stockholm time
UI->>TZ: stockholmNow()
TZ->>ST: getAccurateNow()
ST-->>TZ: accurateUtcNow (with cached offset)
TZ-->>UI: tz.TZDateTime(Stockholm)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pubspec.lockis excluded by!**/*.lock
📒 Files selected for processing (7)
lib/features/event/presentation/screens/booked_events_screen.dart(1 hunks)lib/features/event/presentation/screens/event_detail_screen.dart(1 hunks)lib/features/event/presentation/screens/event_screen.dart(1 hunks)lib/main.dart(2 hunks)lib/shared/infrastructure/services/server_time_service.dart(1 hunks)lib/shared/infrastructure/services/timezone_service.dart(2 hunks)pubspec.yaml(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
lib/**/presentation/screens/**/*.dart
📄 CodeRabbit inference engine (CLAUDE.md)
lib/**/presentation/screens/**/*.dart: Reset command state in initState using addPostFrameCallback to avoid stale UI state
Use GoRouter context.go/push/pop for navigation; do not use Navigator directly
Only navigate after a command isCompleted and has no error
Invoke ViewModel methods for actions; never execute commands directly from UI
Files:
lib/features/event/presentation/screens/event_detail_screen.dartlib/features/event/presentation/screens/booked_events_screen.dartlib/features/event/presentation/screens/event_screen.dart
**/*.dart
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.dart: Use snake_case for file names, PascalCase for classes, camelCase for variables, and _prefix for private members
Wrap debug logging with kDebugMode and avoid production prints of sensitive data
Files:
lib/features/event/presentation/screens/event_detail_screen.dartlib/features/event/presentation/screens/booked_events_screen.dartlib/features/event/presentation/screens/event_screen.dartlib/shared/infrastructure/services/timezone_service.dartlib/main.dartlib/shared/infrastructure/services/server_time_service.dart
pubspec.yaml
📄 CodeRabbit inference engine (CLAUDE.md)
Never use 'any' for dependencies; specify version ranges (e.g., dio: ^5.x)
Files:
pubspec.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build Flutter Web
| // Log to Sentry for monitoring (graceful fallback, not an error) | ||
| Sentry.logger.info( | ||
| 'NTP sync failed, using device time', | ||
| attributes: { | ||
| 'component': SentryLogAttribute.string('ServerTimeService'), | ||
| 'error': SentryLogAttribute.string(e.toString()), | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace unsupported Sentry logging API
Sentry.logger and SentryLogAttribute are not part of sentry_flutter 9.6.0, so this block will not compile. Please switch to a supported API (e.g., Sentry.captureMessage with SentryLevel.info, or a breadcrumb) or drop the structured attributes.
NTP-based time synchronization to prevent users from bypassing timeline validation by manipulating their device time.
Summary by CodeRabbit