Skip to content

Commit

Permalink
TW-1862: Fix can't display message in chat (#2095)
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhhdev authored Dec 12, 2024
1 parent 13d7c2f commit 5f1e8ee
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
21 changes: 19 additions & 2 deletions lib/pages/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,14 @@ class ChatController extends State<Chat>

Future<void> requestHistory({
int? historyCount,
StateFilter? filter,
}) async {
if (!timeline!.canRequestHistory) return;
Logs().v('Chat::requestHistory(): Requesting history...');
try {
return timeline!.requestHistory(
historyCount: historyCount ?? _loadHistoryCount,
filter: filter,
);
} catch (err) {
ScaffoldMessenger.of(context).showSnackBar(
Expand Down Expand Up @@ -1732,6 +1734,12 @@ class ChatController extends State<Chat>
_currentChatScrollState = ChatScrollState.scrolling;
}

List<String> get getEventTypeToFilterUnnecessaryEvent => [
EventTypes.Message,
EventTypes.Encrypted,
EventTypes.Sticker,
];

Future<void> _tryRequestHistory() async {
if (timeline == null) return;

Expand All @@ -1748,10 +1756,19 @@ class ChatController extends State<Chat>
if (allMembershipEvents || canRequestHistory) {
try {
await requestHistory(historyCount: _defaultEventCountDisplay)
.then((response) {
Logs().d(
.then((response) async {
Logs().v(
'Chat::_tryRequestHistory():: Try request history success',
);
if (allMembershipEvents) {
await requestHistory(
historyCount: _defaultEventCountDisplay,
filter: StateFilter(
lazyLoadMembers: true,
types: getEventTypeToFilterUnnecessaryEvent,
),
);
}
});
} catch (e) {
Logs().e(
Expand Down
6 changes: 3 additions & 3 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1877,7 +1877,7 @@ packages:
description:
path: "."
ref: "twake-supported-0.22.6"
resolved-ref: "345aab06d195035c48784b23c849825a61c5a79a"
resolved-ref: "04ec6f3b9ece8e64e031cbe5c6e8164dc2ec7f2d"
url: "[email protected]:linagora/matrix-dart-sdk.git"
source: git
version: "0.22.6"
Expand Down Expand Up @@ -3007,10 +3007,10 @@ packages:
dependency: "direct main"
description:
name: url_launcher
sha256: "9d06212b1362abc2f0f0d78e6f09f726608c74e3b9462e8368bb03314aa8d603"
sha256: "6ce1e04375be4eed30548f10a315826fd933c1e493206eab82eed01f438c8d2e"
url: "https://pub.dev"
source: hosted
version: "6.3.1"
version: "6.2.6"
url_launcher_android:
dependency: transitive
description:
Expand Down

0 comments on commit 5f1e8ee

Please sign in to comment.