Implemented per stream subscription recovery with polling fallback
This commit is contained in:
@@ -528,29 +528,41 @@ class _TicketDetailScreenState extends ConsumerState<TicketDetailScreen> {
|
||||
|
||||
_maybeTypingController(widget.ticketId)?.stopTyping();
|
||||
|
||||
final message = await ref
|
||||
.read(ticketsControllerProvider)
|
||||
.sendTicketMessage(ticketId: widget.ticketId, content: content);
|
||||
// Capture mentions and clear the composer immediately so the UI
|
||||
// remains snappy. Perform the network send and notification creation
|
||||
// in a fire-and-forget background Future.
|
||||
final mentionUserIds = _extractMentionedUserIds(
|
||||
content,
|
||||
profiles,
|
||||
currentUserId,
|
||||
);
|
||||
if (mentionUserIds.isNotEmpty && currentUserId != null) {
|
||||
await ref
|
||||
.read(notificationsControllerProvider)
|
||||
.createMentionNotifications(
|
||||
userIds: mentionUserIds,
|
||||
actorId: currentUserId,
|
||||
ticketId: widget.ticketId,
|
||||
messageId: message.id,
|
||||
);
|
||||
}
|
||||
ref.invalidate(ticketMessagesProvider(widget.ticketId));
|
||||
if (mounted) {
|
||||
_messageController.clear();
|
||||
_clearMentions();
|
||||
}
|
||||
|
||||
Future(() async {
|
||||
try {
|
||||
final message = await ref
|
||||
.read(ticketsControllerProvider)
|
||||
.sendTicketMessage(ticketId: widget.ticketId, content: content);
|
||||
|
||||
if (mentionUserIds.isNotEmpty && currentUserId != null) {
|
||||
try {
|
||||
await ref
|
||||
.read(notificationsControllerProvider)
|
||||
.createMentionNotifications(
|
||||
userIds: mentionUserIds,
|
||||
actorId: currentUserId,
|
||||
ticketId: widget.ticketId,
|
||||
messageId: message.id,
|
||||
);
|
||||
} catch (_) {}
|
||||
}
|
||||
} catch (e, st) {
|
||||
debugPrint('sendTicketMessage error: $e\n$st');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
List<String> _extractMentionedUserIds(
|
||||
|
||||
@@ -64,7 +64,7 @@ class _TicketsListScreenState extends ConsumerState<TicketsListScreen> {
|
||||
final profilesAsync = ref.watch(profilesProvider);
|
||||
|
||||
final showSkeleton =
|
||||
realtime.isConnecting ||
|
||||
realtime.isAnyStreamRecovering ||
|
||||
ticketsAsync.maybeWhen(loading: () => true, orElse: () => false) ||
|
||||
officesAsync.maybeWhen(loading: () => true, orElse: () => false) ||
|
||||
profilesAsync.maybeWhen(loading: () => true, orElse: () => false) ||
|
||||
@@ -347,7 +347,7 @@ class _TicketsListScreenState extends ConsumerState<TicketsListScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
const ReconnectOverlay(),
|
||||
const ReconnectIndicator(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user