diff --git a/CHANGES.rst b/CHANGES.rst index c696183646..b661958cc7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,6 +14,7 @@ Improvements: Bug Fix: * MXRestClient: [avatarUrlForUser:success:failure]: the returned url is always nil, thanks to @asydorov (PR #580) and @giomfo. + * MXRoomSummary: fix null Direct Chat displayname / avatar issue caused by limited syncs API break: * MXMediaManager: [downloadMediaFromURL:andSaveAtFilePath:success:failure:] is removed, use [downloadMediaFromMatrixContentURI:withType:inFolder:success:failure] or [downloadThumbnailFromMatrixContentURI:withType:inFolder:toFitViewSize:withMethod:success:failure] instead. diff --git a/MatrixSDK/Data/MXRoomSummary.m b/MatrixSDK/Data/MXRoomSummary.m index fd81aa91f9..1e8993f036 100644 --- a/MatrixSDK/Data/MXRoomSummary.m +++ b/MatrixSDK/Data/MXRoomSummary.m @@ -141,7 +141,17 @@ - (void)resetRoomStateData [room state:^(MXRoomState *roomState) { MXStrongifyAndReturnIfNil(self); - if ([self.mxSession.roomSummaryUpdateDelegate session:self.mxSession updateRoomSummary:self withStateEvents:roomState.stateEvents roomState:roomState]) + BOOL updated = [self.mxSession.roomSummaryUpdateDelegate session:self.mxSession updateRoomSummary:self withStateEvents:roomState.stateEvents roomState:roomState]; + + if (self.displayname == nil || self.avatar == nil) + { + // Avatar and displayname may not be recomputed from the state event list if + // the latter does not contain any `name` or `avatar` event. So, in this case, + // we reapply the Matrix name/avatar calculation algorithm. + updated |= [self.mxSession.roomSummaryUpdateDelegate session:self.mxSession updateRoomSummary:self withServerRoomSummary:nil roomState:roomState]; + } + + if (updated) { [self save:YES]; }