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.

element-hq/element-ios#443

- remove FIXME (the blocker issue SYN-724 has been fixed on server side).
  • Loading branch information
giomfo committed Aug 11, 2016
1 parent 145091c commit a8b97fb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
13 changes: 6 additions & 7 deletions MatrixSDK/Data/MXEventTimeline.m
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,6 @@ - (void)handleRedaction:(MXEvent*)redactionEvent
// Check whether the current room state depends on this redacted event.
if (!redactedEvent || redactedEvent.isState)
{
// FIXME: Is @autoreleasepool block required or not here?
NSMutableArray *stateEvents = [NSMutableArray arrayWithArray:_state.stateEvents];

for (NSInteger index = 0; index < stateEvents.count; index++)
Expand All @@ -585,7 +584,7 @@ - (void)handleRedaction:(MXEvent*)redactionEvent

[stateEvents replaceObjectAtIndex:index withObject:redactedEvent];

// Reset the room state. //FIXME: is it possible to handle only the redacted event?
// Reset the room state.
_state = [[MXRoomState alloc] initWithRoomId:room.roomId andMatrixSession:room.mxSession andDirection:YES];
[self initialiseState:stateEvents];

Expand All @@ -596,7 +595,7 @@ - (void)handleRedaction:(MXEvent*)redactionEvent
}

// Reset the current pagination
// FIXME: Shall we let the kMXRoomStateHasBeenRedactedNotification listener trigger this reset? (like [MXKRoomDataSource reload] do)
// FIXME: Shall we let the kMXRoomDidFlushMessagesNotification listener trigger this reset? (like [MXKRoomDataSource reload] do)
[self resetPagination];

// Notify that room history has been flushed
Expand Down Expand Up @@ -686,10 +685,10 @@ - (void)forceRoomServerSync

NSLog(@"[MXEventTimeline] forceRoomServerSync failed.");

// FIXME: Reload entirely the app?
// [[NSNotificationCenter defaultCenter] postNotificationName:kMXSessionIgnoredUsersDidChangeNotification
// object:room.mxSession
// userInfo:nil];
// Reload entirely the app
[[NSNotificationCenter defaultCenter] postNotificationName:kMXSessionDidCorruptDataNotification
object:room.mxSession
userInfo:nil];
}];
}

Expand Down
21 changes: 8 additions & 13 deletions MatrixSDK/Data/MXRoomState.m
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,7 @@ - (void)handleStateEvent:(MXEvent*)event
membersWithThirdPartyInviteTokenCache[roomMember.thirdPartyInviteToken] = roomMember;
}
}
else// FIXME: In case of redacted membership event (prev_content is missing see SYN-724),
// the room member is then nil: the client considers by mistake the user is no more part of the room...
else
{
// The user is no more part of the room. Remove him.
// This case happens during back pagination: we remove here users when they are not in the room yet.
Expand Down Expand Up @@ -568,17 +567,13 @@ - (NSString*)memberName:(NSString*)userId

if (!member)
{
// FIXME: In case of redacted membership event (prev_content is missing see SYN-724),
// the client considers by mistake that some users are no more part of the room.
// PATCH: we comment the following, else some redacted information re-appear spontaneously.

// // The user may not have joined the room yet. So try to resolve display name from presence data
// // Note: This data may not be available
// MXUser* user = [mxSession userWithUserId:userId];
// if (user && user.displayname.length)
// {
// displayName = user.displayname;
// }
// The user may not have joined the room yet. So try to resolve display name from presence data
// Note: This data may not be available
MXUser* user = [mxSession userWithUserId:userId];
if (user && user.displayname.length)
{
displayName = user.displayname;
}
}
else if (member.displayname.length)
{
Expand Down
8 changes: 8 additions & 0 deletions MatrixSDK/MXSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,17 @@ FOUNDATION_EXPORT NSString *const kMXSessionNotificationEventKey;

/**
Posted when MXSession has detected a change in the `ignoredUsers` property.
The notification object is the concerned session (MXSession instance).
*/
FOUNDATION_EXPORT NSString *const kMXSessionIgnoredUsersDidChangeNotification;

/**
Posted when MXSession data have been corrupted. The listener must reload the session data with a full server sync.
The notification object is the concerned session (MXSession instance).
*/
FOUNDATION_EXPORT NSString *const kMXSessionDidCorruptDataNotification;

#pragma mark - Other constants
/**
Expand Down
1 change: 1 addition & 0 deletions MatrixSDK/MXSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
NSString *const kMXSessionNotificationRoomIdKey = @"roomId";
NSString *const kMXSessionNotificationEventKey = @"event";
NSString *const kMXSessionIgnoredUsersDidChangeNotification = @"kMXSessionIgnoredUsersDidChangeNotification";
NSString *const kMXSessionDidCorruptDataNotification = @"kMXSessionDidCorruptDataNotification";
NSString *const kMXSessionNoRoomTag = @"m.recent"; // Use the same value as matrix-react-sdk

/**
Expand Down

0 comments on commit a8b97fb

Please # to comment.