mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Send writing messages event
This commit is contained in:
parent
dbb2a3f1a1
commit
1e0e2fca52
@ -404,6 +404,10 @@ class ConversationsHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Send a notification to inform that the user is writing a message
|
||||||
|
static Future<void> sendWritingEvent(int convID) async =>
|
||||||
|
await ws("conversations/is_writing", {"convID": convID});
|
||||||
|
|
||||||
/// Turn an API response into a ConversationMessage object
|
/// Turn an API response into a ConversationMessage object
|
||||||
static ConversationMessage apiToConversationMessage(
|
static ConversationMessage apiToConversationMessage(
|
||||||
Map<String, dynamic> map,
|
Map<String, dynamic> map,
|
||||||
|
@ -66,6 +66,8 @@ class _ConversationScreenState extends SafeState<ConversationScreen> {
|
|||||||
ScrollWatcher _scrollController;
|
ScrollWatcher _scrollController;
|
||||||
_OlderMessagesLevel _loadingOlderMessages = _OlderMessagesLevel.NONE;
|
_OlderMessagesLevel _loadingOlderMessages = _OlderMessagesLevel.NONE;
|
||||||
|
|
||||||
|
int _lastWritingEventSent = 0;
|
||||||
|
|
||||||
CancelToken _sendCancel;
|
CancelToken _sendCancel;
|
||||||
double _sendProgress;
|
double _sendProgress;
|
||||||
|
|
||||||
@ -533,7 +535,10 @@ class _ConversationScreenState extends SafeState<ConversationScreen> {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: darkTheme() ? Colors.white : Colors.black,
|
color: darkTheme() ? Colors.white : Colors.black,
|
||||||
),
|
),
|
||||||
onChanged: (s) => setState(() {}),
|
onChanged: (s) {
|
||||||
|
_sendWritingEvent();
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: tr("New message..."),
|
hintText: tr("New message..."),
|
||||||
hintStyle: TextStyle(
|
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
|
/// Request message statistics
|
||||||
void _requestMessageStats(ConversationMessage message) async {
|
void _requestMessageStats(ConversationMessage message) async {
|
||||||
MainController.of(context)
|
MainController.of(context)
|
||||||
|
Loading…
Reference in New Issue
Block a user