App: remove the first-click permission hook only once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -463,6 +463,7 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
// notifications can be real system notifications without a trip to
|
||||
// Settings.
|
||||
GestureBinding.instance.pointerRouter.addGlobalRoute(_askOnFirstPress);
|
||||
_askRouted = true;
|
||||
bindAttentionAckSync(_session.gateway, _ackSync);
|
||||
unawaited(_ackSync.load());
|
||||
unawaited(_attention.load());
|
||||
@@ -599,9 +600,17 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
}
|
||||
}
|
||||
|
||||
bool _askRouted = false;
|
||||
|
||||
void _stopAsking() {
|
||||
if (!_askRouted) return;
|
||||
_askRouted = false;
|
||||
GestureBinding.instance.pointerRouter.removeGlobalRoute(_askOnFirstPress);
|
||||
}
|
||||
|
||||
void _askOnFirstPress(PointerEvent event) {
|
||||
if (event is! PointerDownEvent || !_notifications.loaded) return;
|
||||
GestureBinding.instance.pointerRouter.removeGlobalRoute(_askOnFirstPress);
|
||||
_stopAsking();
|
||||
if (_notifications.permission == NotificationPermissionState.notRequested) {
|
||||
unawaited(_notifications.requestPermission());
|
||||
}
|
||||
@@ -609,7 +618,7 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
GestureBinding.instance.pointerRouter.removeGlobalRoute(_askOnFirstPress);
|
||||
_stopAsking();
|
||||
_tabLocations.dispose();
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
_deliveryHandoff?.dispose();
|
||||
|
||||
Reference in New Issue
Block a user