Merge branch 'develop' into ismail/4384_room_summary_store

This commit is contained in:
ismailgulek
2021-09-28 17:30:39 +03:00
319 changed files with 12712 additions and 2440 deletions
@@ -21,6 +21,8 @@
@protocol MXKRecentCellDataStoring;
@class DiscussionsCount;
@class MXSpace;
/**
List the different modes used to prepare the recents data source.
Each mode corresponds to an application tab: Home, Favourites, People and Rooms.
@@ -73,6 +75,7 @@ extern NSString *const kRecentsDataSourceTapOnDirectoryServerChange;
@property (nonatomic) NSInteger conversationSection;
@property (nonatomic) NSInteger lowPrioritySection;
@property (nonatomic) NSInteger serverNoticeSection;
@property (nonatomic) NSInteger suggestedRoomsSection;
@property (nonatomic, readonly) NSArray<id<MXKRecentCellDataStoring>> *invitesCellDataArray;
@property (nonatomic, readonly) NSArray<id<MXKRecentCellDataStoring>> *favoriteCellDataArray;
@@ -80,6 +83,7 @@ extern NSString *const kRecentsDataSourceTapOnDirectoryServerChange;
@property (nonatomic, readonly) NSArray<id<MXKRecentCellDataStoring>> *conversationCellDataArray;
@property (nonatomic, readonly) NSArray<id<MXKRecentCellDataStoring>> *lowPriorityCellDataArray;
@property (nonatomic, readonly) NSArray<id<MXKRecentCellDataStoring>> *serverNoticeCellDataArray;
@property (nonatomic, readonly) NSArray<id<MXKRecentCellDataStoring>> *suggestedRoomCellDataArray;
@property (nonatomic, readonly) SecureBackupBannerDisplay secureBackupBannerDisplay;
@property (nonatomic, readonly) CrossSigningBannerDisplay crossSigningBannerDisplay;
@@ -35,6 +35,7 @@
#define RECENTSDATASOURCE_SECTION_LOWPRIORITY 0x10
#define RECENTSDATASOURCE_SECTION_SERVERNOTICE 0x20
#define RECENTSDATASOURCE_SECTION_PEOPLE 0x40
#define RECENTSDATASOURCE_SECTION_SUGGESTED 0x80
#define RECENTSDATASOURCE_DEFAULT_SECTION_HEADER_HEIGHT 30.0
@@ -63,7 +64,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
@end
@implementation RecentsDataSource
@synthesize directorySection, invitesSection, favoritesSection, peopleSection, conversationSection, lowPrioritySection, serverNoticeSection, secureBackupBannerSection, crossSigningBannerSection;
@synthesize directorySection, invitesSection, favoritesSection, peopleSection, conversationSection, lowPrioritySection, serverNoticeSection, suggestedRoomsSection, secureBackupBannerSection, crossSigningBannerSection;
@synthesize hiddenCellIndexPath, droppingCellIndexPath, droppingCellBackGroundView;
- (instancetype)init
@@ -87,6 +88,8 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
// Set default data and view classes
[self registerCellDataClass:RecentCellData.class forCellIdentifier:kMXKRecentCellIdentifier];
[self registerSpaceServiceDidBuildGraphNotification];
}
return self;
}
@@ -101,6 +104,11 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
[fetchersContainer addDelegate:self];
}
- (void)dealloc
{
[self unregisterSpaceServiceDidBuildGraphNotification];
}
- (void)resetSectionIndexes
{
crossSigningBannerSection = -1;
@@ -112,9 +120,9 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
conversationSection = -1;
lowPrioritySection = -1;
serverNoticeSection = -1;
suggestedRoomsSection = -1;
}
#pragma mark - Properties
- (NSArray<id<MXKRecentCellDataStoring>> *)invitesCellDataArray
@@ -165,6 +173,10 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
}
return [self mapRoomSummaries:fetchersContainer.serverNoticeRoomListDataFetcher.data.rooms];
}
- (NSArray *)suggestedRoomCellDataArray
{
return state.suggestedRoomCellDataArray;
}
- (DiscussionsCount *)favoriteMissedDiscussionsCount
{
@@ -235,6 +247,23 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
return stickyHeader;
}
#pragma mark - Space Service notifications
- (void)registerSpaceServiceDidBuildGraphNotification
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(spaceServiceDidBuildGraphNotification:) name:MXSpaceService.didBuildSpaceGraph object:nil];
}
- (void)spaceServiceDidBuildGraphNotification:(NSNotification*)notification
{
[self forceRefresh];
}
- (void)unregisterSpaceServiceDidBuildGraphNotification
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:MXSpaceService.didBuildSpaceGraph object:nil];
}
#pragma mark - Key backup setup banner
- (void)registerKeyBackupStateDidChangeNotification
@@ -511,6 +540,11 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
{
serverNoticeSection = sectionsCount++;
}
if (self.suggestedRoomCellDataArray.count > 0)
{
suggestedRoomsSection = sectionsCount++;
}
}
return sectionsCount;
@@ -563,6 +597,10 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
{
count = self.invitesCellDataArray.count;
}
else if (section == suggestedRoomsSection && !(shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_SUGGESTED))
{
count = self.suggestedRoomCellDataArray.count;
}
// Adjust this count according to the potential dragged cell.
if ([self isMovingCellSection:section])
@@ -644,6 +682,11 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
title = NSLocalizedStringFromTable(@"room_recents_invites_section", @"Vector", nil);
}
}
else if (section == suggestedRoomsSection)
{
count = self.suggestedRoomCellDataArray.count;
title = NSLocalizedStringFromTable(@"room_recents_suggested_rooms_section", @"Vector", nil);
}
if (count)
{
@@ -700,6 +743,11 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
totalNotificationCount = fetchersContainer.serverNoticeRoomListDataFetcher.data.counts.totalNotificationCount;
totalHighlightCount = fetchersContainer.serverNoticeRoomListDataFetcher.data.counts.totalHighlightCount;
}
else if (section == suggestedRoomsSection)
{
totalNotificationCount = fetchersContainer.suggestedRoomListDataFetcher.data.counts.totalNotificationCount;
totalHighlightCount = fetchersContainer.suggestedRoomListDataFetcher.data.counts.totalHighlightCount;
}
if (totalNotificationCount)
{
@@ -779,6 +827,10 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
{
sectionBitwise = RECENTSDATASOURCE_SECTION_INVITES;
}
else if (section == suggestedRoomsSection)
{
sectionBitwise = RECENTSDATASOURCE_SECTION_SUGGESTED;
}
}
if (sectionBitwise)
@@ -976,6 +1028,13 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
cellData = self.invitesCellDataArray[cellDataIndex];
}
}
else if (tableSection == suggestedRoomsSection)
{
if (cellDataIndex < self.suggestedRoomCellDataArray.count)
{
cellData = self.suggestedRoomCellDataArray[cellDataIndex];
}
}
return cellData;
}
@@ -1030,9 +1089,9 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
{
for (int index = 0; index < cellDataArray.count; index++)
{
id<MXKRecentCellDataStoring> cellDataStoring = cellDataArray[index];
id<MXKRecentCellDataStoring> cellData = cellDataArray[index];
if ([roomId isEqualToString:cellDataStoring.roomSummary.roomId] && cellDataStoring.mxSession == matrixSession)
if ([roomId isEqualToString:cellData.roomIdentifier] && cellData.mxSession == matrixSession)
{
return index;
}
@@ -1136,12 +1195,77 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
indexPath = [NSIndexPath indexPathForRow:index inSection:serverNoticeSection];
}
}
if (!indexPath && (suggestedRoomsSection >= 0))
{
index = [self cellIndexPosWithRoomId:roomId andMatrixSession:matrixSession within:self.serverNoticeCellDataArray];
if (index != NSNotFound)
{
// Check whether the low priority rooms are shrinked
if (shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_SUGGESTED)
{
return nil;
}
indexPath = [NSIndexPath indexPathForRow:index inSection:serverNoticeSection];
}
}
return indexPath;
}
#pragma mark - MXKDataSourceDelegate
//if (recentsDataSourceMode == RecentsDataSourceModeHome)
//{
//
// else if (recentCellDataStoring.isSuggestedRoom && recentCellDataStoring.spaceChildInfo.roomType != MXRoomTypeSpace)
// {
// MXRoomSummary *roomSummary = [mxSession roomSummaryWithRoomId:recentCellDataStoring.spaceChildInfo.childRoomId];
// if (!roomSummary.isJoined)
// {
// [suggestedRoomCellDataArray addObject:recentCellDataStoring];
// }
// }
// else
// {
// // Hide spaces from home (keep space invites)
// if (room.summary.roomType != MXRoomTypeSpace)
// {
// [conversationCellDataArray addObject:recentCellDataStoring];
// }
// }
//}
//
//else if (recentsDataSourceMode == RecentsDataSourceModeRooms)
//{
// if (recentCellDataStoring.isSuggestedRoom && recentCellDataStoring.spaceChildInfo.roomType != MXRoomTypeSpace)
// {
// MXRoomSummary *roomSummary = [mxSession roomSummaryWithRoomId:recentCellDataStoring.spaceChildInfo.childRoomId];
// BOOL isJoined = roomSummary.membership == MXMembershipJoin || roomSummary.membershipTransitionState == MXMembershipTransitionStateJoined;
// if (!isJoined)
// {
// [suggestedRoomCellDataArray addObject:recentCellDataStoring];
// }
// }
// // Consider only non direct rooms.
// else if (!room.isDirect)
// {
// // Keep only the invites, the favourites and the rooms without tag and room type different from space
// if (room.summary.membership == MXMembershipInvite)
// {
// if (room.summary.roomType != MXRoomTypeSpace && !MXSDKOptions.sharedInstance.autoAcceptRoomInvites)
// {
// [invitesCellDataArray addObject:recentCellDataStoring];
// }
// }
// else if ((!room.accountData.tags.count || room.accountData.tags[kMXRoomTagFavourite]) && room.summary.roomType != MXRoomTypeSpace)
// {
// [conversationCellDataArray addObject:recentCellDataStoring];
// }
// }
//}
- (void)dataSource:(MXKDataSource*)dataSource didCellChange:(id)changes
{
// Refresh is disabled during drag&drop animation
@@ -29,6 +29,7 @@ class RecentsDataSourceState: NSObject {
let conversationCellDataArray: [MXKRecentCellDataStoring]
let lowPriorityCellDataArray: [MXKRecentCellDataStoring]
let serverNoticeCellDataArray: [MXKRecentCellDataStoring]
let suggestedRoomCellDataArray: [MXKRecentCellDataStoring]
// MARK: Discussion counts
let favouriteMissedDiscussionsCount: DiscussionsCount
@@ -42,6 +43,7 @@ class RecentsDataSourceState: NSObject {
conversationCellDataArray: [MXKRecentCellDataStoring],
lowPriorityCellDataArray: [MXKRecentCellDataStoring],
serverNoticeCellDataArray: [MXKRecentCellDataStoring],
suggestedRoomCellDataArray: [MXKRecentCellDataStoring],
favouriteMissedDiscussionsCount: DiscussionsCount,
directMissedDiscussionsCount: DiscussionsCount,
groupMissedDiscussionsCount: DiscussionsCount) {
@@ -51,6 +53,7 @@ class RecentsDataSourceState: NSObject {
self.conversationCellDataArray = conversationCellDataArray
self.lowPriorityCellDataArray = lowPriorityCellDataArray
self.serverNoticeCellDataArray = serverNoticeCellDataArray
self.suggestedRoomCellDataArray = suggestedRoomCellDataArray
self.favouriteMissedDiscussionsCount = favouriteMissedDiscussionsCount
self.directMissedDiscussionsCount = directMissedDiscussionsCount
self.groupMissedDiscussionsCount = groupMissedDiscussionsCount
@@ -49,6 +49,7 @@ public class RecentsRoomListFetchersContainer: NSObject {
}
public private(set) var lowPriorityRoomListDataFetcher: MXRoomListDataFetcher?
public private(set) var serverNoticeRoomListDataFetcher: MXRoomListDataFetcher?
public private(set) var suggestedRoomListDataFetcher: MXRoomListDataFetcher?
private var conversationRoomListDataFetcherForHome: MXRoomListDataFetcher?
private var conversationRoomListDataFetcherForRooms: MXRoomListDataFetcher?
@@ -90,6 +91,9 @@ public class RecentsRoomListFetchersContainer: NSObject {
if let fetcher = serverNoticeRoomListDataFetcher {
result.append(fetcher)
}
if let fetcher = suggestedRoomListDataFetcher {
result.append(fetcher)
}
return result
}
@@ -126,6 +130,10 @@ public class RecentsRoomListFetchersContainer: NSObject {
if let fetcher = serverNoticeRoomListDataFetcher, fetcherTypes.contains(.serverNotice) {
result.append(fetcher)
}
if let fetcher = suggestedRoomListDataFetcher,
fetcherTypes.contains(.suggested) {
result.append(fetcher)
}
return result
}
@@ -423,8 +431,9 @@ private struct FetcherTypes: OptionSet {
static let conversationRooms = FetcherTypes(rawValue: 1 << 5)
static let lowPriority = FetcherTypes(rawValue: 1 << 6)
static let serverNotice = FetcherTypes(rawValue: 1 << 7)
static let suggested = FetcherTypes(rawValue: 1 << 8)
static let none: FetcherTypes = []
static let all: FetcherTypes = [
.invited, .favorited, .directHome, .directPeople, .conversationHome, .conversationRooms, .lowPriority, .serverNotice]
.invited, .favorited, .directHome, .directPeople, .conversationHome, .conversationRooms, .lowPriority, .serverNotice, .suggested]
}