generated from element-hq/.github
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the JoinRoom screen to take advantage of newer APIs and supp…
…ort more joinRule/membership combinations (i.e. invite required, restricted, banned) (#3685) - expose the full RoomPreview and RoomMembershipDetails through their own proxies - implement standard mocks for all the different combinations - converge on a single room info provider - rebuild all the previews - prioritise the preview data over the room one.
- Loading branch information
1 parent
f20847f
commit 8577f53
Showing
48 changed files
with
499 additions
and
243 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// | ||
// Copyright 2025 New Vector Ltd. | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial | ||
// Please see LICENSE files in the repository root for full details. | ||
// | ||
|
||
import Foundation | ||
import MatrixRustSDK | ||
|
||
extension RoomPreviewProxyMock { | ||
struct Configuration { | ||
var roomID = "1" | ||
var canonicalAlias = "#3🌞problem:matrix.org" | ||
var name = "The Three-Body Problem - 三体" | ||
var topic = "“Science and technology were the only keys to opening the door to the future, and people approached science with the faith and sincerity of elementary school students.”" | ||
var avatarURL = URL.mockMXCAvatar.absoluteString | ||
var numJoinedMembers = UInt64(100) | ||
var numActiveMembers = UInt64(100) | ||
var roomType = RoomType.room | ||
var membership: Membership? | ||
var joinRule: JoinRule | ||
} | ||
|
||
static var joinable: RoomPreviewProxyMock { | ||
.init(.init(membership: nil, joinRule: .public)) | ||
} | ||
|
||
static var restricted: RoomPreviewProxyMock { | ||
.init(.init(membership: nil, joinRule: .restricted(rules: []))) | ||
} | ||
|
||
static var inviteRequired: RoomPreviewProxyMock { | ||
.init(.init(membership: nil, joinRule: .invite)) | ||
} | ||
|
||
static func invited(roomID: String? = nil) -> RoomPreviewProxyMock { | ||
if let roomID { | ||
return .init(.init(roomID: roomID, membership: .invited, joinRule: .invite)) | ||
} | ||
|
||
return .init(.init(membership: .invited, joinRule: .invite)) | ||
} | ||
|
||
static var knockable: RoomPreviewProxyMock { | ||
.init(.init(membership: nil, joinRule: .knock)) | ||
} | ||
|
||
static var knockableRestricted: RoomPreviewProxyMock { | ||
.init(.init(membership: nil, joinRule: .knockRestricted(rules: []))) | ||
} | ||
|
||
static var knocked: RoomPreviewProxyMock { | ||
.init(.init(membership: .knocked, joinRule: .knock)) | ||
} | ||
|
||
static var banned: RoomPreviewProxyMock { | ||
.init(.init(membership: .banned, joinRule: .public)) | ||
} | ||
|
||
convenience init(_ configuration: RoomPreviewProxyMock.Configuration) { | ||
self.init() | ||
underlyingInfo = .init(roomPreviewInfo: .init(roomId: configuration.roomID, | ||
canonicalAlias: configuration.canonicalAlias, | ||
name: configuration.name, | ||
topic: configuration.topic, | ||
avatarUrl: configuration.avatarURL, | ||
numJoinedMembers: configuration.numJoinedMembers, | ||
numActiveMembers: configuration.numActiveMembers, | ||
roomType: configuration.roomType, | ||
isHistoryWorldReadable: nil, | ||
membership: configuration.membership, | ||
joinRule: configuration.joinRule, | ||
isDirect: nil, | ||
heroes: nil)) | ||
|
||
let roomMembershipDetails = RoomMembershipDetailsProxyMock() | ||
|
||
let mockMember = RoomMemberProxyMock() | ||
mockMember.userID = "@bob:matrix.org" | ||
mockMember.displayName = "Billy Bob" | ||
mockMember.avatarURL = .mockMXCUserAvatar | ||
mockMember.membershipChangeReason = "Ain't nobody need no reason" | ||
|
||
roomMembershipDetails.senderRoomMember = mockMember | ||
roomMembershipDetails.ownRoomMember = mockMember | ||
|
||
underlyingOwnMembershipDetails = roomMembershipDetails | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.