mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Send writing messages event
This commit is contained in:
@ -66,6 +66,8 @@ class _ConversationScreenState extends SafeState<ConversationScreen> {
|
||||
ScrollWatcher _scrollController;
|
||||
_OlderMessagesLevel _loadingOlderMessages = _OlderMessagesLevel.NONE;
|
||||
|
||||
int _lastWritingEventSent = 0;
|
||||
|
||||
CancelToken _sendCancel;
|
||||
double _sendProgress;
|
||||
|
||||
@ -533,7 +535,10 @@ class _ConversationScreenState extends SafeState<ConversationScreen> {
|
||||
style: TextStyle(
|
||||
color: darkTheme() ? Colors.white : Colors.black,
|
||||
),
|
||||
onChanged: (s) => setState(() {}),
|
||||
onChanged: (s) {
|
||||
_sendWritingEvent();
|
||||
setState(() {});
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
hintText: tr("New message..."),
|
||||
hintStyle: TextStyle(
|
||||
@ -650,6 +655,21 @@ class _ConversationScreenState extends SafeState<ConversationScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
void _sendWritingEvent() async {
|
||||
try {
|
||||
if (textMessage.isEmpty) return;
|
||||
final t = time();
|
||||
|
||||
if (t - _lastWritingEventSent <
|
||||
srvConfig.conversationsPolicy.writingEventInterval) return;
|
||||
|
||||
_lastWritingEventSent = t;
|
||||
await ConversationsHelper.sendWritingEvent(_conversation.id);
|
||||
} catch (e, s) {
|
||||
logError(e, s);
|
||||
}
|
||||
}
|
||||
|
||||
/// Request message statistics
|
||||
void _requestMessageStats(ConversationMessage message) async {
|
||||
MainController.of(context)
|
||||
|
Reference in New Issue
Block a user