mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Workaround: Hold a weak reference to the SDK's Client in MediaLoader so it can be released when clearing the cache.
This commit is contained in:
@@ -2125,6 +2125,11 @@ class ClientProxyMock: ClientProxyProtocol, @unchecked Sendable {
|
||||
}
|
||||
var underlyingHideInviteAvatarsPublisher: CurrentValuePublisher<Bool, Never>!
|
||||
var pusherNotificationClientIdentifier: String?
|
||||
var mediaLoader: MediaLoaderProtocol {
|
||||
get { return underlyingMediaLoader }
|
||||
set(value) { underlyingMediaLoader = value }
|
||||
}
|
||||
var underlyingMediaLoader: MediaLoaderProtocol!
|
||||
var roomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
get { return underlyingRoomSummaryProvider }
|
||||
set(value) { underlyingRoomSummaryProvider = value }
|
||||
@@ -5199,228 +5204,6 @@ class ClientProxyMock: ClientProxyProtocol, @unchecked Sendable {
|
||||
return setHideInviteAvatarsReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - loadMediaContentForSource
|
||||
|
||||
var loadMediaContentForSourceThrowableError: Error?
|
||||
var loadMediaContentForSourceUnderlyingCallsCount = 0
|
||||
var loadMediaContentForSourceCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return loadMediaContentForSourceUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = loadMediaContentForSourceUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
loadMediaContentForSourceUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
loadMediaContentForSourceUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var loadMediaContentForSourceCalled: Bool {
|
||||
return loadMediaContentForSourceCallsCount > 0
|
||||
}
|
||||
var loadMediaContentForSourceReceivedSource: MediaSourceProxy?
|
||||
var loadMediaContentForSourceReceivedInvocations: [MediaSourceProxy] = []
|
||||
|
||||
var loadMediaContentForSourceUnderlyingReturnValue: Data!
|
||||
var loadMediaContentForSourceReturnValue: Data! {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return loadMediaContentForSourceUnderlyingReturnValue
|
||||
} else {
|
||||
var returnValue: Data? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = loadMediaContentForSourceUnderlyingReturnValue
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
loadMediaContentForSourceUnderlyingReturnValue = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
loadMediaContentForSourceUnderlyingReturnValue = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var loadMediaContentForSourceClosure: ((MediaSourceProxy) async throws -> Data)?
|
||||
|
||||
func loadMediaContentForSource(_ source: MediaSourceProxy) async throws -> Data {
|
||||
if let error = loadMediaContentForSourceThrowableError {
|
||||
throw error
|
||||
}
|
||||
loadMediaContentForSourceCallsCount += 1
|
||||
loadMediaContentForSourceReceivedSource = source
|
||||
DispatchQueue.main.async {
|
||||
self.loadMediaContentForSourceReceivedInvocations.append(source)
|
||||
}
|
||||
if let loadMediaContentForSourceClosure = loadMediaContentForSourceClosure {
|
||||
return try await loadMediaContentForSourceClosure(source)
|
||||
} else {
|
||||
return loadMediaContentForSourceReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - loadMediaThumbnailForSource
|
||||
|
||||
var loadMediaThumbnailForSourceWidthHeightThrowableError: Error?
|
||||
var loadMediaThumbnailForSourceWidthHeightUnderlyingCallsCount = 0
|
||||
var loadMediaThumbnailForSourceWidthHeightCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return loadMediaThumbnailForSourceWidthHeightUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = loadMediaThumbnailForSourceWidthHeightUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
loadMediaThumbnailForSourceWidthHeightUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
loadMediaThumbnailForSourceWidthHeightUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var loadMediaThumbnailForSourceWidthHeightCalled: Bool {
|
||||
return loadMediaThumbnailForSourceWidthHeightCallsCount > 0
|
||||
}
|
||||
var loadMediaThumbnailForSourceWidthHeightReceivedArguments: (source: MediaSourceProxy, width: UInt, height: UInt)?
|
||||
var loadMediaThumbnailForSourceWidthHeightReceivedInvocations: [(source: MediaSourceProxy, width: UInt, height: UInt)] = []
|
||||
|
||||
var loadMediaThumbnailForSourceWidthHeightUnderlyingReturnValue: Data!
|
||||
var loadMediaThumbnailForSourceWidthHeightReturnValue: Data! {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return loadMediaThumbnailForSourceWidthHeightUnderlyingReturnValue
|
||||
} else {
|
||||
var returnValue: Data? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = loadMediaThumbnailForSourceWidthHeightUnderlyingReturnValue
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
loadMediaThumbnailForSourceWidthHeightUnderlyingReturnValue = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
loadMediaThumbnailForSourceWidthHeightUnderlyingReturnValue = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var loadMediaThumbnailForSourceWidthHeightClosure: ((MediaSourceProxy, UInt, UInt) async throws -> Data)?
|
||||
|
||||
func loadMediaThumbnailForSource(_ source: MediaSourceProxy, width: UInt, height: UInt) async throws -> Data {
|
||||
if let error = loadMediaThumbnailForSourceWidthHeightThrowableError {
|
||||
throw error
|
||||
}
|
||||
loadMediaThumbnailForSourceWidthHeightCallsCount += 1
|
||||
loadMediaThumbnailForSourceWidthHeightReceivedArguments = (source: source, width: width, height: height)
|
||||
DispatchQueue.main.async {
|
||||
self.loadMediaThumbnailForSourceWidthHeightReceivedInvocations.append((source: source, width: width, height: height))
|
||||
}
|
||||
if let loadMediaThumbnailForSourceWidthHeightClosure = loadMediaThumbnailForSourceWidthHeightClosure {
|
||||
return try await loadMediaThumbnailForSourceWidthHeightClosure(source, width, height)
|
||||
} else {
|
||||
return loadMediaThumbnailForSourceWidthHeightReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - loadMediaFileForSource
|
||||
|
||||
var loadMediaFileForSourceFilenameThrowableError: Error?
|
||||
var loadMediaFileForSourceFilenameUnderlyingCallsCount = 0
|
||||
var loadMediaFileForSourceFilenameCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return loadMediaFileForSourceFilenameUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = loadMediaFileForSourceFilenameUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
loadMediaFileForSourceFilenameUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
loadMediaFileForSourceFilenameUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var loadMediaFileForSourceFilenameCalled: Bool {
|
||||
return loadMediaFileForSourceFilenameCallsCount > 0
|
||||
}
|
||||
var loadMediaFileForSourceFilenameReceivedArguments: (source: MediaSourceProxy, filename: String?)?
|
||||
var loadMediaFileForSourceFilenameReceivedInvocations: [(source: MediaSourceProxy, filename: String?)] = []
|
||||
|
||||
var loadMediaFileForSourceFilenameUnderlyingReturnValue: MediaFileHandleProxy!
|
||||
var loadMediaFileForSourceFilenameReturnValue: MediaFileHandleProxy! {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return loadMediaFileForSourceFilenameUnderlyingReturnValue
|
||||
} else {
|
||||
var returnValue: MediaFileHandleProxy? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = loadMediaFileForSourceFilenameUnderlyingReturnValue
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
loadMediaFileForSourceFilenameUnderlyingReturnValue = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
loadMediaFileForSourceFilenameUnderlyingReturnValue = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var loadMediaFileForSourceFilenameClosure: ((MediaSourceProxy, String?) async throws -> MediaFileHandleProxy)?
|
||||
|
||||
func loadMediaFileForSource(_ source: MediaSourceProxy, filename: String?) async throws -> MediaFileHandleProxy {
|
||||
if let error = loadMediaFileForSourceFilenameThrowableError {
|
||||
throw error
|
||||
}
|
||||
loadMediaFileForSourceFilenameCallsCount += 1
|
||||
loadMediaFileForSourceFilenameReceivedArguments = (source: source, filename: filename)
|
||||
DispatchQueue.main.async {
|
||||
self.loadMediaFileForSourceFilenameReceivedInvocations.append((source: source, filename: filename))
|
||||
}
|
||||
if let loadMediaFileForSourceFilenameClosure = loadMediaFileForSourceFilenameClosure {
|
||||
return try await loadMediaFileForSourceFilenameClosure(source, filename)
|
||||
} else {
|
||||
return loadMediaFileForSourceFilenameReturnValue
|
||||
}
|
||||
}
|
||||
}
|
||||
class CompletionSuggestionServiceMock: CompletionSuggestionServiceProtocol, @unchecked Sendable {
|
||||
var suggestionsPublisher: AnyPublisher<[SuggestionItem], Never> {
|
||||
|
||||
Reference in New Issue
Block a user