Cancel background tasks and clear feature scopes
Ensure sign-out cleans up background work and feature state: import BackgroundTaskService and FeatureGate, invoke BackgroundTaskService.cancelAll() inside a try/catch in the sign-out finally block, and call FeatureGate.instance.clearScopes(). Existing client/staff session clearing and handleSignOut() are preserved.
This commit is contained in:
@@ -4,7 +4,9 @@ import 'package:krow_domain/krow_domain.dart';
|
|||||||
|
|
||||||
import '../api_service/api_service.dart';
|
import '../api_service/api_service.dart';
|
||||||
import '../api_service/endpoints/auth_endpoints.dart';
|
import '../api_service/endpoints/auth_endpoints.dart';
|
||||||
|
import '../api_service/feature_gate.dart';
|
||||||
import '../api_service/mixins/session_handler_mixin.dart';
|
import '../api_service/mixins/session_handler_mixin.dart';
|
||||||
|
import '../device/background_task/background_task_service.dart';
|
||||||
import 'client_session_store.dart';
|
import 'client_session_store.dart';
|
||||||
import 'staff_session_store.dart';
|
import 'staff_session_store.dart';
|
||||||
|
|
||||||
@@ -110,8 +112,16 @@ class V2SessionService with SessionHandlerMixin {
|
|||||||
debugPrint('[V2SessionService] Error signing out: $e');
|
debugPrint('[V2SessionService] Error signing out: $e');
|
||||||
rethrow;
|
rethrow;
|
||||||
} finally {
|
} finally {
|
||||||
|
// Cancel all background tasks (geofence tracking, etc.).
|
||||||
|
try {
|
||||||
|
await const BackgroundTaskService().cancelAll();
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('[V2SessionService] Failed to cancel background tasks: $e');
|
||||||
|
}
|
||||||
|
|
||||||
StaffSessionStore.instance.clear();
|
StaffSessionStore.instance.clear();
|
||||||
ClientSessionStore.instance.clear();
|
ClientSessionStore.instance.clear();
|
||||||
|
FeatureGate.instance.clearScopes();
|
||||||
handleSignOut();
|
handleSignOut();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user