Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BF: Room summary is not updated after redaction of the room display name #476

Merged
merged 2 commits into from
Mar 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use the existing resetRoomStateData method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk. It may be better.


[self resetRoomStateData];
}
}

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