RoomDataSource: Handle current user location sharing status.

This commit is contained in:
SBiOSoftWhare
2022-03-28 10:16:07 +02:00
parent 56a31a0d13
commit 56dbadf356
2 changed files with 35 additions and 0 deletions
@@ -56,6 +56,8 @@ const CGFloat kTypingCellHeight = 24;
@property (nonatomic) NSInteger typingCellIndex;
@property(nonatomic, readwrite) BOOL isCurrentUserSharingIsLocation;
@end
@implementation RoomDataSource
@@ -131,6 +133,8 @@ const CGFloat kTypingCellHeight = 24;
}
self.showTypingRow = YES;
[self updateCurrentUserLocationSharingStatus];
}
- (id<RoomDataSourceDelegate>)roomDataSourceDelegate
@@ -225,6 +229,8 @@ const CGFloat kTypingCellHeight = 24;
- (void)roomSummaryDidChange:(NSNotification*)notification
{
[self updateCurrentUserLocationSharingStatus];
if (!self.room.summary.isEncrypted)
{
return;
@@ -1130,4 +1136,27 @@ const CGFloat kTypingCellHeight = 24;
didTapThread:summaryView.thread];
}
#pragma mark - Location sharing
- (void)updateCurrentUserLocationSharingStatus
{
MXLocationService *locationService = self.mxSession.locationService;
if (!locationService || !self.roomId)
{
return;
}
BOOL isUserSharingIsLocation = [locationService isCurrentUserSharingIsLocationInRoomWithId:self.roomId];
if (isUserSharingIsLocation != self.isCurrentUserSharingIsLocation)
{
self.isCurrentUserSharingIsLocation = [locationService isCurrentUserSharingIsLocationInRoomWithId:self.roomId];
dispatch_async(dispatch_get_main_queue(), ^{
[self.roomDataSourceDelegate roomDataSourceDidUpdateCurrentUserSharingLocationStatus:self];
});
}
}
@end