fix(ui): fix stopTyping unhandled exceptions when network is off or spotty. (#1296)

* feat(llc, ui): Introduce `keyStrokeHandler` to properly handle keyStrokes.

Signed-off-by: xsahil03x <[email protected]>

* chore(ui): update CHANGELOG.md

Signed-off-by: xsahil03x <[email protected]>

* test(llc): add key_stroke_handler_test.dart

Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
Sahil Kumar
2022-08-05 16:57:32 +02:00
committed by GitHub
parent b3a7ca2897
commit bd1876c159
8 changed files with 352 additions and 149 deletions
@@ -1,3 +1,10 @@
## Upcoming
🐞 Fixed
- [[#882]](https://github.com/GetStream/stream-chat-flutter/issues/882) Lots of unhandled exceptions
when network is off or spotty.
## 4.4.1
🐞 Fixed
@@ -824,9 +824,14 @@ class MessageInputState extends State<MessageInput> {
value = value.trim();
final channel = StreamChannel.of(context).channel;
if (value.isNotEmpty) {
// ignore: no-empty-block
channel.keyStroke(widget.parentMessage?.id).catchError((e) {});
if (value.isNotEmpty &&
channel.ownCapabilities.contains(PermissionType.sendTypingEvents)) {
// Notify the server that the user started typing.
channel.keyStroke(widget.parentMessage?.id).onError(
(error, stackTrace) {
widget.onError?.call(error!, stackTrace);
},
);
}
var actionsLength = widget.actions.length;
@@ -945,12 +945,14 @@ class StreamMessageInputState extends State<StreamMessageInput>
value = value.trim();
final channel = StreamChannel.of(context).channel;
if (channel.ownCapabilities.contains(PermissionType.sendTypingEvents) &&
value.isNotEmpty) {
channel
.keyStroke(_effectiveController.value.parentId)
// ignore: no-empty-block
.catchError((e) {});
if (value.isNotEmpty &&
channel.ownCapabilities.contains(PermissionType.sendTypingEvents)) {
// Notify the server that the user started typing.
channel.keyStroke(_effectiveController.message.parentId).onError(
(error, stackTrace) {
widget.onError?.call(error!, stackTrace);
},
);
}
var actionsLength = widget.actions.length;