Skip to content

Commit

Permalink
Merge pull request #476 from matrix-org/riot_1822
Browse files Browse the repository at this point in the history
BF: Room summary is not updated after redaction of the room display name
  • Loading branch information
manuroe committed Mar 27, 2018
2 parents 777f17e + bc4386d commit caf09a3
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions MatrixSDK/Data/MXRoomSummary.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,10 @@ - (instancetype)initWithRoomId:(NSString *)theRoomId andMatrixSession:(MXSession
if (self)
{
_roomId = theRoomId;
_mxSession = matrixSession;
_lastMessageOthers = [NSMutableDictionary dictionary];
_others = [NSMutableDictionary dictionary];

// Listen to the event sent state changes
// This is used to follow evolution of local echo events
// (ex: when a sentState change from sending to sentFailed)
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(eventDidChangeSentState:) name:kMXEventDidChangeSentStateNotification object:nil];
[self setMatrixSession:matrixSession];
}

return self;
Expand All @@ -60,12 +56,26 @@ - (void)destroy
NSLog(@"[MXKRoomSummary] Destroy %p - room id: %@", self, _roomId);

[[NSNotificationCenter defaultCenter] removeObserver:self name:kMXEventDidChangeSentStateNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:kMXRoomDidFlushDataNotification object:nil];
}

- (void)setMatrixSession:(MXSession *)mxSession
{
_mxSession = mxSession;
}
if (!_mxSession)
{
_mxSession = mxSession;

// Listen to the event sent state changes
// This is used to follow evolution of local echo events
// (ex: when a sentState change from sending to sentFailed)
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(eventDidChangeSentState:) name:kMXEventDidChangeSentStateNotification object:nil];

// Listen to data being flush in a room
// This is used to update the room summary in case of a state event redaction
// We may need to update the room displayname when it happens
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(roomDidFlushData:) name:kMXRoomDidFlushDataNotification object:nil];
}
}

- (void)save:(BOOL)commit
{
Expand Down Expand Up @@ -314,6 +324,16 @@ - (void)eventDidChangeSentState:(NSNotification *)notif
}
}

- (void)roomDidFlushData:(NSNotification *)notif
{
MXRoom *room = notif.object;
if (_mxSession == room.mxSession && [_roomId isEqualToString:room.state.roomId])
{
NSLog(@"[MXRoomSummary] roomDidFlushData: %@", _roomId);

[self resetRoomStateData];
}
}

#pragma mark - Others
- (NSUInteger)localUnreadEventCount
Expand Down

0 comments on commit caf09a3

Please sign in to comment.