Skip to content

Commit

Permalink
update breadcrumb list when leaving a room
Browse files Browse the repository at this point in the history
  • Loading branch information
JanNikGra committed Apr 19, 2023
1 parent d72008e commit 9fec550
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 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 removeBreadcrumbWithRoomId: roomId];

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

// update breadcrub list when leaving a room
- (void)removeBreadcrumbWithRoomId:(NSString *)roomId
{
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: nil failure: nil];
}

#pragma mark - Homeserver information
- (MXWellKnown *)homeserverWellknown
{
Expand Down

0 comments on commit 9fec550

Please sign in to comment.