mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Knocking feature polishing part 2 (#3738)
* improved implementation of the unknown state * forget button in the banned state * error handling for forbidden access * added the forget function fixed DMs, and updated preview tests * removed banned room proxy * code polishing and test improvement
This commit is contained in:
@@ -13393,6 +13393,70 @@ class RoomPreviewProxyMock: RoomPreviewProxyProtocol, @unchecked Sendable {
|
||||
var underlyingOwnMembershipDetails: RoomMembershipDetailsProxyProtocol?
|
||||
var ownMembershipDetailsClosure: (() async -> RoomMembershipDetailsProxyProtocol?)?
|
||||
|
||||
//MARK: - forgetRoom
|
||||
|
||||
var forgetRoomUnderlyingCallsCount = 0
|
||||
var forgetRoomCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return forgetRoomUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = forgetRoomUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
forgetRoomUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
forgetRoomUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var forgetRoomCalled: Bool {
|
||||
return forgetRoomCallsCount > 0
|
||||
}
|
||||
|
||||
var forgetRoomUnderlyingReturnValue: Result<Void, RoomProxyError>!
|
||||
var forgetRoomReturnValue: Result<Void, RoomProxyError>! {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return forgetRoomUnderlyingReturnValue
|
||||
} else {
|
||||
var returnValue: Result<Void, RoomProxyError>? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = forgetRoomUnderlyingReturnValue
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
forgetRoomUnderlyingReturnValue = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
forgetRoomUnderlyingReturnValue = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var forgetRoomClosure: (() async -> Result<Void, RoomProxyError>)?
|
||||
|
||||
func forgetRoom() async -> Result<Void, RoomProxyError> {
|
||||
forgetRoomCallsCount += 1
|
||||
if let forgetRoomClosure = forgetRoomClosure {
|
||||
return await forgetRoomClosure()
|
||||
} else {
|
||||
return forgetRoomReturnValue
|
||||
}
|
||||
}
|
||||
}
|
||||
class RoomProxyMock: RoomProxyProtocol, @unchecked Sendable {
|
||||
var id: String {
|
||||
|
||||
@@ -11429,6 +11429,46 @@ open class RoomSDKMock: MatrixRustSDK.Room, @unchecked Sendable {
|
||||
enableSendQueueEnableClosure?(enable)
|
||||
}
|
||||
|
||||
//MARK: - forget
|
||||
|
||||
open var forgetThrowableError: Error?
|
||||
var forgetUnderlyingCallsCount = 0
|
||||
open var forgetCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return forgetUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = forgetUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
forgetUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
forgetUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
open var forgetCalled: Bool {
|
||||
return forgetCallsCount > 0
|
||||
}
|
||||
open var forgetClosure: (() async throws -> Void)?
|
||||
|
||||
open override func forget() async throws {
|
||||
if let error = forgetThrowableError {
|
||||
throw error
|
||||
}
|
||||
forgetCallsCount += 1
|
||||
try await forgetClosure?()
|
||||
}
|
||||
|
||||
//MARK: - getPowerLevels
|
||||
|
||||
open var getPowerLevelsThrowableError: Error?
|
||||
@@ -19421,6 +19461,71 @@ open class SyncServiceBuilderSDKMock: MatrixRustSDK.SyncServiceBuilder, @uncheck
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - withOfflineMode
|
||||
|
||||
var withOfflineModeUnderlyingCallsCount = 0
|
||||
open var withOfflineModeCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return withOfflineModeUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = withOfflineModeUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
withOfflineModeUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
withOfflineModeUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
open var withOfflineModeCalled: Bool {
|
||||
return withOfflineModeCallsCount > 0
|
||||
}
|
||||
|
||||
var withOfflineModeUnderlyingReturnValue: SyncServiceBuilder!
|
||||
open var withOfflineModeReturnValue: SyncServiceBuilder! {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return withOfflineModeUnderlyingReturnValue
|
||||
} else {
|
||||
var returnValue: SyncServiceBuilder? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = withOfflineModeUnderlyingReturnValue
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
withOfflineModeUnderlyingReturnValue = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
withOfflineModeUnderlyingReturnValue = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
open var withOfflineModeClosure: (() -> SyncServiceBuilder)?
|
||||
|
||||
open override func withOfflineMode() -> SyncServiceBuilder {
|
||||
withOfflineModeCallsCount += 1
|
||||
if let withOfflineModeClosure = withOfflineModeClosure {
|
||||
return withOfflineModeClosure()
|
||||
} else {
|
||||
return withOfflineModeReturnValue
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - withUtdHook
|
||||
|
||||
var withUtdHookDelegateUnderlyingCallsCount = 0
|
||||
|
||||
Reference in New Issue
Block a user