DM Details View (#744)

* Basic implementation completed but it requires some bug fixing and polishing (+4 squashed commits)
Squashed commits:
[43f0064e] now the content of the room details reflects the expected dm details content when the conditions are met
[fe6f2b5e] replaced existing headers with a composable and reusable HeaderView
[3c00120a] now the members are fetched every time the room is opened
[421d539b] refactored the members fetching to be immediate in case the room could be a direct chat

* polished the code and fixed some bugs that prevented the updated state of the members to be displayed in the room details view (+1 squashed commit)
Squashed commits:
[6bf98473] fix for the button not being destructive in room details screen

* removed copy button and updated copy

* moved a file and renamed header view

* addressed all PR comments

* sdk bump

* UI tests

* unit tests

* changelog

* updated mocks

* removed a duplicated signature in a mock
This commit is contained in:
Mauro
2023-04-03 13:18:19 +02:00
committed by GitHub
parent 220138d492
commit 0f858d977f
35 changed files with 1241 additions and 241 deletions
+12 -8
View File
@@ -34,6 +34,11 @@ class RoomProxy: RoomProxyProtocol {
private(set) var displayName: String?
private var timelineObservationToken: TaskHandle?
private let membersSubject = CurrentValueSubject<[RoomMemberProxyProtocol], Never>([])
var membersPublisher: AnyPublisher<[RoomMemberProxyProtocol], Never> {
membersSubject.eraseToAnyPublisher()
}
init(slidingSyncRoom: SlidingSyncRoomProtocol,
room: RoomProtocol,
@@ -140,6 +145,7 @@ class RoomProxy: RoomProxyProtocol {
timelineObservationToken = result.taskHandle
Task {
await fetchMembers()
await updateMembers()
}
return .success(result.items)
} else {
@@ -274,18 +280,16 @@ class RoomProxy: RoomProxyProtocol {
}
}
}
func members() async -> Result<[RoomMemberProxyProtocol], RoomProxyError> {
func updateMembers() async {
do {
let members = try await Task.dispatch(on: .global()) {
let members = try self.room.members()
return members
let roomMembers = try await Task.dispatch(on: .global()) {
try self.room.members()
}
let proxiedMembers = buildRoomMemberProxies(members: members)
return .success(proxiedMembers)
membersSubject.value = buildRoomMemberProxies(members: roomMembers)
} catch {
return .failure(.failedRetrievingMembers)
return
}
}
@@ -54,7 +54,9 @@ protocol RoomProxyProtocol {
var topic: String? { get }
var avatarURL: URL? { get }
var membersPublisher: AnyPublisher<[RoomMemberProxyProtocol], Never> { get }
func loadAvatarURLForUserId(_ userId: String) async -> Result<URL?, RoomProxyError>
func loadDisplayNameForUserId(_ userId: String) async -> Result<String?, RoomProxyError>
@@ -79,13 +81,13 @@ protocol RoomProxyProtocol {
func reportContent(_ eventID: String, reason: String?) async -> Result<Void, RoomProxyError>
func members() async -> Result<[RoomMemberProxyProtocol], RoomProxyError>
func ignoreUser(_ userID: String) async -> Result<Void, RoomProxyError>
func retryDecryption(for sessionID: String) async
func leaveRoom() async -> Result<Void, RoomProxyError>
func updateMembers() async
}
extension RoomProxyProtocol {
@@ -0,0 +1,36 @@
//
// Copyright 2023 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
struct RoomMemberDetails: Identifiable, Equatable {
let id: String
let name: String?
let avatarURL: URL?
let permalink: URL?
let isAccountOwner: Bool
var isIgnored: Bool
@MainActor
init(withProxy proxy: RoomMemberProxyProtocol) {
id = proxy.userID
name = proxy.displayName
avatarURL = proxy.avatarURL
permalink = proxy.permalink
isAccountOwner = proxy.isAccountOwner
isIgnored = proxy.isIgnored
}
}