mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 19:11:45 +00:00
Knocked Preview implementation (#3426)
* JoinRoomScreen ui for knocking * code improvement * updated previews * added knocked state with tests * send knock request * Apply suggestions from code review Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com> * pr comments * update tests * new API * knock implementation and cancel knock * update strings * added a knocked cell in the home screen * design update * updated SDK * simplified the invite case code * pr comments * updated previews * added message as reason * updated strings * fixing tests --------- Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
This commit is contained in:
@@ -76,7 +76,11 @@ class KnockedRoomProxy: KnockedRoomProxyProtocol {
|
||||
}
|
||||
|
||||
func cancelKnock() async -> Result<Void, RoomProxyError> {
|
||||
// TODO: Implement this once the API is available
|
||||
.failure(.invalidURL)
|
||||
do {
|
||||
return try await .success(room.leave())
|
||||
} catch {
|
||||
MXLog.error("Failed cancelling the knock with error: \(error)")
|
||||
return .failure(.sdkError(error))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,32 @@ import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
struct RoomSummary {
|
||||
enum JoinRequestType {
|
||||
case invite(inviter: RoomMemberProxyProtocol?)
|
||||
case knock
|
||||
|
||||
var isInvite: Bool {
|
||||
if case .invite = self {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
var isKnock: Bool {
|
||||
if case .knock = self {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let roomListItem: RoomListItem
|
||||
|
||||
let id: String
|
||||
|
||||
let isInvite: Bool
|
||||
let inviter: RoomMemberProxyProtocol?
|
||||
let joinRequestType: JoinRequestType?
|
||||
|
||||
let name: String
|
||||
let isDirect: Bool
|
||||
@@ -67,10 +87,9 @@ extension RoomSummary {
|
||||
unreadNotificationsCount = hasUnreadNotifications ? 1 : 0
|
||||
notificationMode = settingsMode
|
||||
canonicalAlias = nil
|
||||
inviter = nil
|
||||
hasOngoingCall = false
|
||||
|
||||
isInvite = false
|
||||
joinRequestType = nil
|
||||
isMarkedUnread = false
|
||||
isFavourite = false
|
||||
}
|
||||
|
||||
@@ -255,10 +255,15 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
|
||||
let notificationMode = roomInfo.cachedUserDefinedNotificationMode.flatMap { RoomNotificationModeProxy.from(roomNotificationMode: $0) }
|
||||
|
||||
let joinRequestType: RoomSummary.JoinRequestType? = switch roomInfo.membership {
|
||||
case .invited: .invite(inviter: inviterProxy)
|
||||
case .knocked: .knock
|
||||
default: nil
|
||||
}
|
||||
|
||||
return RoomSummary(roomListItem: roomListItem,
|
||||
id: roomInfo.id,
|
||||
isInvite: roomInfo.membership == .invited,
|
||||
inviter: inviterProxy,
|
||||
joinRequestType: joinRequestType,
|
||||
name: roomInfo.displayName ?? roomInfo.id,
|
||||
isDirect: roomInfo.isDirect,
|
||||
avatarURL: roomInfo.avatarUrl.flatMap(URL.init(string:)),
|
||||
|
||||
Reference in New Issue
Block a user