Skip to content

Commit

Permalink
Merge pull request #1777 from bwi-de/update-breadcrumb-list-when-leav…
Browse files Browse the repository at this point in the history
…ing-room

Update breadcrumb list when leaving room
  • Loading branch information
nimau authored Apr 27, 2023
2 parents 98e7c1c + fc76004 commit da17ebf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
39 changes: 39 additions & 0 deletions MatrixSDK/MXSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -3070,6 +3070,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 @@ -4629,6 +4631,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.

0 comments on commit da17ebf

Please sign in to comment.