Sync Needs-you dismissals and chat read state across devices
This commit is contained in:
@@ -13,6 +13,8 @@ import '../shell/destination.dart';
|
||||
import '../features/attention/notify/notification_controller.dart';
|
||||
import '../features/attention/notify/chat_question_notices.dart';
|
||||
import '../features/attention/notify/notification_store.dart';
|
||||
import '../features/attention/runtime/attention_ack_queue.dart';
|
||||
import '../features/attention/runtime/attention_ack_sync.dart';
|
||||
import '../features/attention/runtime/attention_controller.dart';
|
||||
import '../features/attention/runtime/attention_store.dart';
|
||||
import '../features/runs/ui/run_search_selection.dart';
|
||||
@@ -126,6 +128,18 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
store: SharedPreferencesAttentionStore(
|
||||
serverId: serverStorageScope(widget.serverId),
|
||||
),
|
||||
sync: _ackSync,
|
||||
);
|
||||
|
||||
/// Shares Needs-you dismissals and chat read watermarks with every device
|
||||
/// through the server. Bound to the gateway so the chat list (created by its
|
||||
/// destination) uses the same channel; refreshed on every connection.
|
||||
late final AttentionAckSync _ackSync = AttentionAckSync(
|
||||
gateway: _session.gateway,
|
||||
sendOnly: _session.client.sendOnly,
|
||||
queue: SharedPreferencesAttentionAckQueue(
|
||||
serverId: serverStorageScope(widget.serverId),
|
||||
),
|
||||
);
|
||||
StreamSubscription<JsonMap>? _attentionFrames;
|
||||
int _attentionEpoch = 0;
|
||||
@@ -169,6 +183,8 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
if (mounted) _delegate.goTo(AppRoute.run(id));
|
||||
};
|
||||
unawaited(_notifications.load());
|
||||
bindAttentionAckSync(_session.gateway, _ackSync);
|
||||
unawaited(_ackSync.load());
|
||||
unawaited(_attention.load());
|
||||
_attentionFrames = _session.gateway.frames
|
||||
.where((frame) => frame['type'] == 'run_event')
|
||||
@@ -216,6 +232,8 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
unawaited(_attentionFrames?.cancel());
|
||||
_attention.removeListener(_attentionChanged);
|
||||
_attention.dispose();
|
||||
bindAttentionAckSync(_session.gateway, null);
|
||||
_ackSync.dispose();
|
||||
_attentionCount.dispose();
|
||||
_notifications.dispose();
|
||||
_chatQuestionNotices?.dispose();
|
||||
@@ -275,6 +293,9 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
if (epoch == _attentionEpoch) return;
|
||||
_attentionEpoch = epoch;
|
||||
_attention.resetForReconnect();
|
||||
// Every connected transition sends acknowledgements queued while offline
|
||||
// and re-reads the shared set, so a gap cannot leave this device stale.
|
||||
if (_session.connected) unawaited(_ackSync.connected());
|
||||
}
|
||||
|
||||
/// Mirrors the controller's entry count for the shell. The Runs list seeds
|
||||
|
||||
Reference in New Issue
Block a user