Skip to content

Commit

Permalink
Redacting membership events should immediately reset the displayname …
Browse files Browse the repository at this point in the history
…& avatar of room members.

#443

Fix Manu's comments (matrix-org/matrix-ios-sdk#118)
  • Loading branch information
giomfo committed Aug 12, 2016
1 parent 5009263 commit e11b365
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
9 changes: 9 additions & 0 deletions Vector/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,15 @@ - (void)initMatrixSessions

}];

[[NSNotificationCenter defaultCenter] addObserverForName:kMXSessionDidCorruptDataNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull notif) {

NSLog(@"[AppDelegate] kMXSessionDidCorruptDataNotification received. Reload the app");

// Reload entirely the app when a session has corrupted its data
[[AppDelegate theDelegate] reloadMatrixSessions:YES];

}];

// Observe settings changes
[[MXKAppSettings standardAppSettings] addObserver:self forKeyPath:@"showAllEventsInRoomHistory" options:0 context:nil];

Expand Down
18 changes: 9 additions & 9 deletions Vector/ViewController/RoomParticipantsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ @interface RoomParticipantsViewController ()
// 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;
// Observe kMXRoomDidFlushDataNotification to take into account the updated room members when the room history is flushed.
id roomDidFlushDataNotificationObserver;

RoomMemberDetailsViewController *memberDetailsViewController;

Expand Down Expand Up @@ -154,10 +154,10 @@ - (void)destroy
leaveRoomNotificationObserver = nil;
}

if (roomDidFlushMessagesNotificationObserver)
if (roomDidFlushDataNotificationObserver)
{
[[NSNotificationCenter defaultCenter] removeObserver:roomDidFlushMessagesNotificationObserver];
roomDidFlushMessagesNotificationObserver = nil;
[[NSNotificationCenter defaultCenter] removeObserver:roomDidFlushDataNotificationObserver];
roomDidFlushDataNotificationObserver = nil;
}

if (membersListener)
Expand Down Expand Up @@ -266,10 +266,10 @@ - (void)setMxRoom:(MXRoom *)mxRoom
[[NSNotificationCenter defaultCenter] removeObserver:leaveRoomNotificationObserver];
leaveRoomNotificationObserver = nil;
}
if (roomDidFlushMessagesNotificationObserver)
if (roomDidFlushDataNotificationObserver)
{
[[NSNotificationCenter defaultCenter] removeObserver:roomDidFlushMessagesNotificationObserver];
roomDidFlushMessagesNotificationObserver = nil;
[[NSNotificationCenter defaultCenter] removeObserver:roomDidFlushDataNotificationObserver];
roomDidFlushDataNotificationObserver = nil;
}
if (membersListener)
{
Expand Down Expand Up @@ -300,7 +300,7 @@ - (void)setMxRoom:(MXRoom *)mxRoom
}];

// 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) {
roomDidFlushDataNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXRoomDidFlushDataNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {

MXRoom *room = notif.object;
if (_mxRoom.mxSession == room.mxSession && [_mxRoom.state.roomId isEqualToString:room.state.roomId])
Expand Down

0 comments on commit e11b365

Please # to comment.