Skip to content

Commit

Permalink
Update All chats screen with latest design #6407
Browse files Browse the repository at this point in the history
- update after code review
  • Loading branch information
gileluard committed Aug 1, 2022
1 parent 54d4ccb commit 9c80cbb
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 34 deletions.
8 changes: 0 additions & 8 deletions MatrixSDK/Data/MXRoomSummary.m
Original file line number Diff line number Diff line change
Expand Up @@ -1098,10 +1098,6 @@ - (MXRoomSummaryDataTypes)calculateDataTypes
{
result |= MXRoomSummaryDataTypesDirect;
}
else
{
result |= MXRoomSummaryDataTypesNotDirect;
}
if (self.roomType == MXRoomTypeSpace)
{
result |= MXRoomSummaryDataTypesSpace;
Expand All @@ -1114,10 +1110,6 @@ - (MXRoomSummaryDataTypes)calculateDataTypes
{
result |= MXRoomSummaryDataTypesUnread;
}
else
{
result |= MXRoomSummaryDataTypesRead;
}

return result;
}
Expand Down
4 changes: 1 addition & 3 deletions MatrixSDK/Data/MXRoomSummaryDataTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ typedef NS_OPTIONS(NSInteger, MXRoomSummaryDataTypes)
MXRoomSummaryDataTypesHidden = 1 << 5,
MXRoomSummaryDataTypesSpace = 1 << 6,
MXRoomSummaryDataTypesConferenceUser = 1 << 7,
MXRoomSummaryDataTypesNotDirect = 1 << 8,
MXRoomSummaryDataTypesUnread = 1 << 9,
MXRoomSummaryDataTypesRead = 1 << 10,
MXRoomSummaryDataTypesUnread = 1 << 8
};

#endif /* MXRoomSummaryDataTypes_h */
17 changes: 4 additions & 13 deletions MatrixSDK/Data/RoomList/Common/MXRecentsRoomListDataFetcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,13 @@ internal class MXRecentsRoomListDataFetcher: NSObject, MXRoomListDataFetcher {
// MARK: - Public

func refresh() {
guard let events = session?.accountData.accountData["events"] as? [[AnyHashable: Any]] else {
MXLog.error("[MXRecentsRoomListDataFetcher] cannot retrieve events")
guard let breadcrumbs = session?.accountData?.accountData(forEventType: kMXAccountDataTypeBreadcrumbs) as? [AnyHashable: [String]] else {
MXLog.warning("[MXRecentsRoomListDataFetcher] cannot retrieve breadcrumbs")
return
}

var breadcrumbs: [AnyHashable: [String]]?
for event in events {
if let type = event["type"] as? String,
type == kMXAccountDataTypeBreadcrumbs,
let content = event["content"] as? [AnyHashable: [String]] {
breadcrumbs = content
}
}

guard var recentRoomIds = breadcrumbs?[kMXAccountDataTypeRecentRoomsKey] else {
MXLog.error("[MXRecentsRoomListDataFetcher] cannot retrieve recent rooms")
guard var recentRoomIds = breadcrumbs[kMXAccountDataTypeRecentRoomsKey] else {
MXLog.warning("[MXRecentsRoomListDataFetcher] cannot retrieve recent rooms")
return
}

Expand Down
2 changes: 2 additions & 0 deletions MatrixSDK/Data/RoomList/MXRoomListDataFilterOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ public struct MXRoomListDataFilterOptions: Equatable {
/// Flag to show only rooms that matches all the provided `dataTypes`. This has no effect when `onlySuggested` is `true`
public let strictMatches: Bool

///Flag to fetch and order rooms according room IDs stored in the `im.vector.setting.breadcrumbs` event within the user account data.
public let onlyBreadcrumbs: Bool

/// Initializer
/// - Parameters:
/// - dataTypes: data types to fetch. Pass `MXRoomListDataFilterOptions.emptyDataTypes` not to specify any.
/// - notDataTypes: data types not to fetch. Pass `MXRoomListDataFilterOptions.emptyDataTypes` not to specify any.
/// - onlySuggested: flag to filter only suggested rooms. Only `space` and `query` parameters are honored if true.
/// - onlyBreadcrumbs: flag to fetch and order rooms according room IDs stored in the `im.vector.setting.breadcrumbs` event within the user account data.
/// - query: search query
/// - space: active space
/// - showAllRoomsInHomeSpace: flag to show all rooms in home space (when `space` is not provided)
Expand Down
5 changes: 5 additions & 0 deletions MatrixSDK/Data/RoomList/MXRoomListDataSortOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,17 @@ public struct MXRoomListDataSortOptions: Equatable {
/// Related fetcher will be refreshed automatically when updated.
public var unreadMessagesFirst: Bool

/// Flag to sort rooms alphabetically.
/// Related fetcher will be refreshed automatically when updated.
public var alphabetical: Bool

/// Initializer
/// - Parameters:
/// - sentStatus: flag to sort by sent status
/// - lastEventDate: flag to sort by last event date
/// - favoriteTag: Flag to sort by favorite tag order
/// - suggested: Flag to sort by suggested room flag
/// - alphabetical: Flag to sort rooms alphabetically
/// - missedNotificationsFirst: flag to sort by missed notification count
/// - unreadMessagesFirst: flag to sort by unread count
public init(invitesFirst: Bool = true,
Expand Down
11 changes: 1 addition & 10 deletions MatrixSDK/MXSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -4470,16 +4470,7 @@ - (void)updateBreadcrumbsWithRoomWithId:(NSString *)roomId
success:(void (^)(void))success
failure:(void (^)(NSError *error))failure
{
NSArray<NSDictionary *> *events = self.accountData.accountData[@"events"];

NSDictionary<NSString *, NSArray *> *breadcrumbs;
for (NSDictionary * event in events)
{
if ([event[@"type"] isEqualToString:kMXAccountDataTypeBreadcrumbs])
{
breadcrumbs = event[@"content"];
}
}
NSDictionary<NSString *, NSArray *> *breadcrumbs = [self.accountData accountDataForEventType:kMXAccountDataTypeBreadcrumbs];

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

Expand Down

0 comments on commit 9c80cbb

Please sign in to comment.