Skip to content

Commit

Permalink
TW-499: filter events when group chat change avatar or name when crea…
Browse files Browse the repository at this point in the history
…ting new chat
  • Loading branch information
sherlockvn authored and hoangdat committed Sep 19, 2023
1 parent 5e472c6 commit 86dcd92
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/utils/matrix_sdk_extensions/filtered_timeline_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ extension IsStateExtension on Event {
content.tryGet<String>('membership') == 'ban' ||
!isSomeoneChangeDisplayName() &&
!isSomeoneChangeAvatar() &&
!isGroupNameChangeWhenCreate() &&
!isGroupAvatarChangeWhenCreate() &&
!isActivateEndToEndEncryption() &&

static const Set<String> importantStateEvents = {
Expand All @@ -37,6 +39,8 @@ extension IsStateExtension on Event {
EventTypes.RoomMember,
EventTypes.RoomTombstone,
EventTypes.CallInvite,
EventTypes.RoomName,
EventTypes.RoomAvatar,
};

bool get isState => !{
Expand All @@ -49,6 +53,17 @@ extension IsStateExtension on Event {
prevContent?['displayname'] != null &&
prevContent!['displayname'] != content['displayname'];
}
bool isGroupNameChangeWhenCreate() {
return type == EventTypes.RoomName &&
content['name'] != null &&
prevContent?['name'] == null;
}

bool isGroupAvatarChangeWhenCreate() {
return type == EventTypes.RoomAvatar &&
content['url'] == null &&
prevContent?['url'] == null;
}
bool isSomeoneChangeAvatar() {
return stateKey != null &&
prevContent?["membership"] == 'join' &&
Expand Down

0 comments on commit 86dcd92

Please sign in to comment.