mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Knock and knocked state for the join room screen (#3424)
* 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 --------- Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
This commit is contained in:
@@ -415,6 +415,30 @@ class ClientProxy: ClientProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func knockRoom(_ roomID: String, message: String?) async -> Result<Void, ClientProxyError> {
|
||||
do {
|
||||
// TODO: It should also include a message but the API for is not available yet
|
||||
let _ = try await client.knock(roomIdOrAlias: roomID)
|
||||
await waitForRoomToSync(roomID: roomID, timeout: .seconds(30))
|
||||
return .success(())
|
||||
} catch {
|
||||
MXLog.error("Failed knocking roomID: \(roomID) with error: \(error)")
|
||||
return .failure(.sdkError(error))
|
||||
}
|
||||
}
|
||||
|
||||
func knockRoomAlias(_ roomAlias: String, message: String?) async -> Result<Void, ClientProxyError> {
|
||||
do {
|
||||
// TODO: It should also include a message but the API for is not available yet
|
||||
let room = try await client.knock(roomIdOrAlias: roomAlias)
|
||||
await waitForRoomToSync(roomID: room.id(), timeout: .seconds(30))
|
||||
return .success(())
|
||||
} catch {
|
||||
MXLog.error("Failed knocking roomAlias: \(roomAlias) with error: \(error)")
|
||||
return .failure(.sdkError(error))
|
||||
}
|
||||
}
|
||||
|
||||
func uploadMedia(_ media: MediaInfo) async -> Result<String, ClientProxyError> {
|
||||
guard let mimeType = media.mimeType else {
|
||||
MXLog.error("Failed uploading media, invalid mime type: \(media)")
|
||||
@@ -846,9 +870,17 @@ class ClientProxy: ClientProxyProtocol {
|
||||
let roomListItem = try roomListService.room(roomId: roomID)
|
||||
|
||||
switch roomListItem.membership() {
|
||||
case .invited, .knocked:
|
||||
case .invited:
|
||||
return try .invited(InvitedRoomProxy(roomListItem: roomListItem,
|
||||
room: roomListItem.invitedRoom()))
|
||||
case .knocked:
|
||||
if appSettings.knockingEnabled {
|
||||
return try .knocked(KnockedRoomProxy(roomListItem: roomListItem,
|
||||
room: roomListItem.invitedRoom()))
|
||||
} else {
|
||||
return try .invited(InvitedRoomProxy(roomListItem: roomListItem,
|
||||
room: roomListItem.invitedRoom()))
|
||||
}
|
||||
case .joined:
|
||||
if roomListItem.isTimelineInitialized() == false {
|
||||
try await roomListItem.initTimeline(eventTypeFilter: eventFilters, internalIdPrefix: nil)
|
||||
|
||||
@@ -145,6 +145,10 @@ protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol {
|
||||
|
||||
func joinRoomAlias(_ roomAlias: String) async -> Result<Void, ClientProxyError>
|
||||
|
||||
func knockRoom(_ roomID: String, message: String?) async -> Result<Void, ClientProxyError>
|
||||
|
||||
func knockRoomAlias(_ roomAlias: String, message: String?) async -> Result<Void, ClientProxyError>
|
||||
|
||||
func uploadMedia(_ media: MediaInfo) async -> Result<String, ClientProxyError>
|
||||
|
||||
func roomForIdentifier(_ identifier: String) async -> RoomProxyType?
|
||||
|
||||
Reference in New Issue
Block a user