handleLoggedOut method
Public handler for post-logout local cleanup, completing the handleAuthenticated/handleAboutToLogOut/handleLoggedOut trio.
Resets the cached sync markers (timezone / offset / last-server-sync /
last-touch) so the NEXT login's change-detection does not compare against
the previous user's cached values (BEH-21). Purely local and non-blocking —
it does NOT touch the backend (the device doc is deleted by
handleAboutToLogOut before signOut). Idempotent under the double
onLoggedOut fire.
Usage
// Race-free initialization pattern:
final deviceService = DeviceServiceImpl();
final auth = AuthServiceImpl(
firebaseApp: app,
onLoggedOutCallbacks: [
PrioritizedCallback(deviceService.handleLoggedOut, priority: 0),
],
);
Implementation
@override
Future<void> handleLoggedOut() async {
// BEH-21/FCM-013: reset the cached sync markers so the NEXT login's
// change-detection never compares against the previous user's cached values
// (which would otherwise suppress the new user's first timezone/touch sync).
// Idempotent under the double onLoggedOut fire (plain field resets, BEH-18).
// The device doc itself is deleted by handleAboutToLogOut (before signOut);
// this is a purely local, non-blocking reset.
logv('DeviceService: handleLoggedOut called — resetting cached sync markers');
_cachedTimezone = null;
_cachedOffsetMinutes = null;
_lastServerSyncAt = null;
_lastTouchAt = null;
}