Auto Task Assignment
This commit is contained in:
@@ -482,7 +482,9 @@ class _TicketDetailScreenState extends ConsumerState<TicketDetailScreen> {
|
||||
if (!canSendMessages) return;
|
||||
final content = _messageController.text.trim();
|
||||
if (content.isEmpty) return;
|
||||
ref.read(typingIndicatorProvider(widget.ticketId).notifier).stopTyping();
|
||||
|
||||
_maybeTypingController(widget.ticketId)?.stopTyping();
|
||||
|
||||
final message = await ref
|
||||
.read(ticketsControllerProvider)
|
||||
.sendTicketMessage(ticketId: widget.ticketId, content: content);
|
||||
@@ -533,11 +535,11 @@ class _TicketDetailScreenState extends ConsumerState<TicketDetailScreen> {
|
||||
bool canSendMessages,
|
||||
) {
|
||||
if (!canSendMessages) {
|
||||
ref.read(typingIndicatorProvider(widget.ticketId).notifier).stopTyping();
|
||||
_maybeTypingController(widget.ticketId)?.stopTyping();
|
||||
_clearMentions();
|
||||
return;
|
||||
}
|
||||
ref.read(typingIndicatorProvider(widget.ticketId).notifier).userTyping();
|
||||
_maybeTypingController(widget.ticketId)?.userTyping();
|
||||
final text = _messageController.text;
|
||||
final cursor = _messageController.selection.baseOffset;
|
||||
if (cursor < 0) {
|
||||
@@ -585,6 +587,18 @@ class _TicketDetailScreenState extends ConsumerState<TicketDetailScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
// Safely obtain the typing controller for [ticketId].
|
||||
TypingIndicatorController? _maybeTypingController(String ticketId) {
|
||||
try {
|
||||
final controller = ref.read(typingIndicatorProvider(ticketId).notifier);
|
||||
return controller.mounted ? controller : null;
|
||||
} on StateError {
|
||||
return null;
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
bool _isWhitespace(String char) {
|
||||
return char.trim().isEmpty;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user