mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-02 14:16:59 +02:00
Redacting membership events should immediately reset the displayname & avatar of room members.
vector-im/vector-ios#443 Refresh Room members list on state event redaction
This commit is contained in:
@@ -58,6 +58,9 @@
|
||||
|
||||
// Observe kMXSessionWillLeaveRoomNotification to be notified if the user leaves the current room.
|
||||
id leaveRoomNotificationObserver;
|
||||
|
||||
// Observe kMXRoomDidFlushMessagesNotification to take into account the updated room members when the room history is flushed.
|
||||
id roomDidFlushMessagesNotificationObserver;
|
||||
|
||||
RoomMemberDetailsViewController *memberDetailsViewController;
|
||||
|
||||
@@ -151,6 +154,12 @@
|
||||
leaveRoomNotificationObserver = nil;
|
||||
}
|
||||
|
||||
if (roomDidFlushMessagesNotificationObserver)
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:roomDidFlushMessagesNotificationObserver];
|
||||
roomDidFlushMessagesNotificationObserver = nil;
|
||||
}
|
||||
|
||||
if (membersListener)
|
||||
{
|
||||
[self.mxRoom.liveTimeline removeListener:membersListener];
|
||||
@@ -257,6 +266,11 @@
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:leaveRoomNotificationObserver];
|
||||
leaveRoomNotificationObserver = nil;
|
||||
}
|
||||
if (roomDidFlushMessagesNotificationObserver)
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:roomDidFlushMessagesNotificationObserver];
|
||||
roomDidFlushMessagesNotificationObserver = nil;
|
||||
}
|
||||
if (membersListener)
|
||||
{
|
||||
[_mxRoom.liveTimeline removeListener:membersListener];
|
||||
@@ -285,6 +299,20 @@
|
||||
}
|
||||
}];
|
||||
|
||||
// Observe room history flush (sync with limited timeline, or state event redaction)
|
||||
roomDidFlushMessagesNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXRoomDidFlushMessagesNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
|
||||
|
||||
MXRoom *room = notif.object;
|
||||
if (_mxRoom.mxSession == room.mxSession && [_mxRoom.state.roomId isEqualToString:room.state.roomId])
|
||||
{
|
||||
// The existing room history has been flushed during server sync. Take into account the updated room members list.
|
||||
[self refreshParticipantsFromRoomMembers];
|
||||
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
}];
|
||||
|
||||
// Register a listener for events that concern room members
|
||||
NSArray *mxMembersEvents = @[kMXEventTypeStringRoomMember, kMXEventTypeStringRoomThirdPartyInvite, kMXEventTypeStringRoomPowerLevels];
|
||||
membersListener = [_mxRoom.liveTimeline listenToEventsOfTypes:mxMembersEvents onEvent:^(MXEvent *event, MXTimelineDirection direction, id customObject) {
|
||||
|
||||
Reference in New Issue
Block a user