Skip to content

fix: 🐛 prevent actions if receiver is not capable of dealing with them #192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
send message not working when user start texting after newLine.
* **Fix**: [191](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/191) Fix
error when using `BuildContext` or `State` extensions when not mounted.
* **Fix**: [192](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/192) Fix
send to closed socket or animate on `ScrollController` without clients.

## [1.3.1]

Expand Down
25 changes: 17 additions & 8 deletions lib/src/controller/chat_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ class ChatController {
/// Used to add message in message list.
void addMessage(Message message) {
initialMessageList.add(message);
messageStreamController.sink.add(initialMessageList);
if (!messageStreamController.isClosed) {
messageStreamController.sink.add(initialMessageList);
}
}

/// Used to add reply suggestions.
Expand Down Expand Up @@ -134,24 +136,31 @@ class ChatController {
messageType: message.messageType,
status: message.status,
);
messageStreamController.sink.add(initialMessageList);
if (!messageStreamController.isClosed) {
messageStreamController.sink.add(initialMessageList);
}
}

/// Function to scroll to last messages in chat view
void scrollToLastMessage() => Timer(
const Duration(milliseconds: 300),
() => scrollController.animateTo(
scrollController.position.minScrollExtent,
curve: Curves.easeIn,
duration: const Duration(milliseconds: 300),
),
() {
if (!scrollController.hasClients) return;
scrollController.animateTo(
scrollController.position.minScrollExtent,
curve: Curves.easeIn,
duration: const Duration(milliseconds: 300),
);
},
);

/// Function for loading data while pagination.
void loadMoreData(List<Message> messageList) {
/// Here, we have passed 0 index as we need to add data before first data
initialMessageList.insertAll(0, messageList);
messageStreamController.sink.add(initialMessageList);
if (!messageStreamController.isClosed) {
messageStreamController.sink.add(initialMessageList);
}
}

/// Function for getting ChatUser object from user id
Expand Down