Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix room previews #1283

Merged
merged 3 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions MatrixSDK/Data/RoomList/MXRoomListDataFilterOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public struct MXRoomListDataFilterOptions: Equatable {
/// Flag to filter only suggested rooms, if set to `true`, `dataTypes` and `notDataTypes` are not valid.
public let onlySuggested: Bool

/// Flag to hide any rooms where the user's membership is unknown. This has no effect when `onlySuggested` is `true`.
/// When set to `false`, rooms that have been cached during peeking may be included in the filtered results.
public let hideUnknownMembershipRooms: Bool

/// Initializer
/// - Parameters:
/// - dataTypes: data types to fetch. Pass `MXRoomListDataFilterOptions.emptyDataTypes` not to specify any.
Expand All @@ -50,13 +54,15 @@ public struct MXRoomListDataFilterOptions: Equatable {
onlySuggested: Bool = false,
query: String? = nil,
space: MXSpace? = nil,
showAllRoomsInHomeSpace: Bool) {
showAllRoomsInHomeSpace: Bool,
hideUnknownMembershipRooms: Bool = true) {
self.dataTypes = dataTypes
self.notDataTypes = notDataTypes
self.onlySuggested = onlySuggested
self.query = query
self.space = space
self.showAllRoomsInHomeSpace = showAllRoomsInHomeSpace
self.hideUnknownMembershipRooms = hideUnknownMembershipRooms
}

/// Just to be used for in-memory data
Expand All @@ -83,6 +89,12 @@ public struct MXRoomListDataFilterOptions: Equatable {
}

if !onlySuggested {
if hideUnknownMembershipRooms {
let memberPredicate = NSPredicate(format: "%K != %d",
#keyPath(MXRoomSummaryProtocol.membership), MXMembership.unknown.rawValue)
subpredicates.append(memberPredicate)
}

if !dataTypes.isEmpty {
let subpredicate = NSPredicate(format: "(%K & %d) != 0",
#keyPath(MXRoomSummaryProtocol.dataTypes), dataTypes.rawValue)
Expand Down Expand Up @@ -119,9 +131,9 @@ public struct MXRoomListDataFilterOptions: Equatable {
#keyPath(MXRoomSummaryProtocol.dataTypes), favoritedDataTypes.rawValue)

let subpredicate4_1 = NSPredicate(format: "%K == NULL",
#keyPath(MXRoomSummaryProtocol.parentSpaceIds))
#keyPath(MXRoomSummaryProtocol.parentSpaceIds))
let subpredicate4_2 = NSPredicate(format: "%K.@count == 0",
#keyPath(MXRoomSummaryProtocol.parentSpaceIds))
#keyPath(MXRoomSummaryProtocol.parentSpaceIds))
let subpredicate4 = NSCompoundPredicate(type: .or,
subpredicates: [subpredicate4_1, subpredicate4_2])

Expand Down
10 changes: 10 additions & 0 deletions MatrixSDK/MXSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,16 @@ FOUNDATION_EXPORT NSString *const kMXSessionNoRoomTag;
*/
@property (nonatomic, readonly, getter=isPauseable) BOOL pauseable;

/**
Whether the user is part of a room with the membership state of `join` or
they are in the process of joining.

@param roomIdOrAlias The ID or alias of the room to check.

@return YES if they are.
*/
- (BOOL)isJoinedOnRoom:(NSString *)roomIdOrAlias;
ismailgulek marked this conversation as resolved.
Show resolved Hide resolved

#pragma mark - Class methods

/**
Expand Down
1 change: 1 addition & 0 deletions changelog.d/5083.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MXRoomListDataFilterOptions: Filter out any cached room previews.