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

Update breadcrumb list when leaving room #1777

Merged
Merged
Show file tree
Hide file tree
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
39 changes: 39 additions & 0 deletions MatrixSDK/MXSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -3199,6 +3199,8 @@ - (void)removeRoom:(NSString *)roomId
// And remove the room and its summary from the list
[rooms removeObjectForKey:roomId];
[roomSummaries removeObjectForKey:roomId];
// Remove room from breadcrub list
[self removeBreadcrumbWithRoomWithId:roomId success:nil failure:nil];

// Broadcast the left room
[[NSNotificationCenter defaultCenter] postNotificationName:kMXSessionDidLeaveRoomNotification
Expand Down Expand Up @@ -4758,6 +4760,43 @@ - (void)updateBreadcrumbsWithRoomWithId:(NSString *)roomId
}];
}

// Update breadcrub list when leaving a room
- (void)removeBreadcrumbWithRoomWithId:(NSString *)roomId
success:(void (^)(void))success
failure:(void (^)(NSError *error))failure
{
NSDictionary<NSString *, NSArray *> *breadcrumbs = [self.accountData accountDataForEventType:kMXAccountDataTypeBreadcrumbs];

NSMutableArray<NSString *> *recentRoomIds = breadcrumbs[kMXAccountDataTypeRecentRoomsKey] ? [NSMutableArray arrayWithArray:breadcrumbs[kMXAccountDataTypeRecentRoomsKey]] : [NSMutableArray array];

NSInteger index = [recentRoomIds indexOfObject:roomId];
if (index != NSNotFound)
{
[recentRoomIds removeObjectAtIndex:index];

[self setAccountData:@{kMXAccountDataTypeRecentRoomsKey : recentRoomIds}
forType:kMXAccountDataTypeBreadcrumbs
success:^{
if (success)
{
success();
}
} failure:^(NSError *error) {
if (failure)
{
failure(error);
}
}];
}
else
{
if (success)
{
success();
}
}
}

#pragma mark - Homeserver information
- (MXWellKnown *)homeserverWellknown
{
Expand Down
1 change: 1 addition & 0 deletions changelog.d/1777.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix breadcrumb list not updating when leaving a room. Contributed by @JanNikGra.