🐛 Make sure the send read event triggered before dispose chat message controller
This commit is contained in:
parent
5468fc0748
commit
c8c455bb57
@ -514,23 +514,30 @@ class ChatMessageController extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_readEventDebounce = Timer(const Duration(milliseconds: 500), () {
|
_readEventDebounce = Timer(const Duration(milliseconds: 500), () {
|
||||||
_ws.conn?.sink.add(jsonEncode(
|
_sendReadEvent();
|
||||||
WebSocketPackage(
|
|
||||||
method: 'events.read',
|
|
||||||
endpoint: 'im',
|
|
||||||
payload: {
|
|
||||||
'channel_member_id': profile!.id,
|
|
||||||
'event_id': _readEventAnchor,
|
|
||||||
},
|
|
||||||
).toJson(),
|
|
||||||
));
|
|
||||||
log('[Messaging] Send read event request: $_readEventAnchor');
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _sendReadEvent() {
|
||||||
|
_ws.conn?.sink.add(jsonEncode(
|
||||||
|
WebSocketPackage(
|
||||||
|
method: 'events.read',
|
||||||
|
endpoint: 'im',
|
||||||
|
payload: {
|
||||||
|
'channel_member_id': profile!.id,
|
||||||
|
'event_id': _readEventAnchor,
|
||||||
|
},
|
||||||
|
).toJson(),
|
||||||
|
));
|
||||||
|
log('[Messaging] Send read event request: $_readEventAnchor');
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_wsSubscription?.cancel();
|
_wsSubscription?.cancel();
|
||||||
|
if (_readEventDebounce?.isActive ?? false) {
|
||||||
|
_sendReadEvent();
|
||||||
|
}
|
||||||
_readEventDebounce?.cancel();
|
_readEventDebounce?.cancel();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user