mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 20:09:04 +00:00
using roomPreview API for invited rooms (#3530)
* using roomPreview for invited rooms * Update ElementX/Sources/Services/Room/RoomInfoProxy.swift Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com> * improved code * fix, but requires a SDK PR * update sdk * package resolved * fixed the tests --------- Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
This commit is contained in:
@@ -16,6 +16,8 @@ protocol BaseRoomInfoProxyProtocol {
|
||||
var canonicalAlias: String? { get }
|
||||
var avatarURL: URL? { get }
|
||||
var activeMembersCount: Int { get }
|
||||
var isDirect: Bool { get }
|
||||
var isSpace: Bool { get }
|
||||
}
|
||||
|
||||
struct RoomInfoProxy: BaseRoomInfoProxyProtocol {
|
||||
@@ -70,12 +72,22 @@ struct RoomPreviewInfoProxy: BaseRoomInfoProxyProtocol {
|
||||
|
||||
var id: String { roomPreviewInfo.roomId }
|
||||
var displayName: String? { roomPreviewInfo.name }
|
||||
var avatar: RoomAvatar {
|
||||
.room(id: id, name: displayName, avatarURL: avatarURL)
|
||||
}
|
||||
|
||||
var heroes: [RoomHero] { roomPreviewInfo.heroes ?? [] }
|
||||
var topic: String? { roomPreviewInfo.topic }
|
||||
var canonicalAlias: String? { roomPreviewInfo.canonicalAlias }
|
||||
var avatarURL: URL? { roomPreviewInfo.avatarUrl.flatMap(URL.init) }
|
||||
var activeMembersCount: Int { Int(roomPreviewInfo.numJoinedMembers) }
|
||||
var isDirect: Bool { roomPreviewInfo.isDirect ?? false }
|
||||
var isSpace: Bool { roomPreviewInfo.roomType == .space }
|
||||
var activeMembersCount: Int { Int(roomPreviewInfo.numActiveMembers ?? roomPreviewInfo.numJoinedMembers) }
|
||||
|
||||
/// The room's avatar info for use in a ``RoomAvatarImage``.
|
||||
var avatar: RoomAvatar {
|
||||
if isDirect, avatarURL == nil {
|
||||
if heroes.count == 1 {
|
||||
return .heroes(heroes.map(UserProfileProxy.init))
|
||||
}
|
||||
}
|
||||
|
||||
return .room(id: id, name: displayName, avatarURL: avatarURL)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user