Use the room heroes when computing a DM avatar. (#2900)

* Use room heroes for DM avatar content ID.

* Use RoomAvatar.heroes for the DM Details stack.
This commit is contained in:
Doug
2024-06-19 11:27:10 +01:00
committed by GitHub
parent 17d96b0f4b
commit 834260c144
55 changed files with 524 additions and 198 deletions
@@ -8056,6 +8056,11 @@ class RoomProxyMock: RoomProxyProtocol {
var underlyingOwnUserID: String!
var name: String?
var topic: String?
var avatar: RoomAvatar {
get { return underlyingAvatar }
set(value) { underlyingAvatar = value }
}
var underlyingAvatar: RoomAvatar!
var avatarURL: URL?
var membersPublisher: CurrentValuePublisher<[RoomMemberProxyProtocol], Never> {
get { return underlyingMembersPublisher }
@@ -10733,6 +10733,71 @@ open class RoomSDKMock: MatrixRustSDK.Room {
}
}
//MARK: - heroes
var heroesUnderlyingCallsCount = 0
open var heroesCallsCount: Int {
get {
if Thread.isMainThread {
return heroesUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = heroesUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
heroesUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
heroesUnderlyingCallsCount = newValue
}
}
}
}
open var heroesCalled: Bool {
return heroesCallsCount > 0
}
var heroesUnderlyingReturnValue: [RoomHero]!
open var heroesReturnValue: [RoomHero]! {
get {
if Thread.isMainThread {
return heroesUnderlyingReturnValue
} else {
var returnValue: [RoomHero]? = nil
DispatchQueue.main.sync {
returnValue = heroesUnderlyingReturnValue
}
return returnValue!
}
}
set {
if Thread.isMainThread {
heroesUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
heroesUnderlyingReturnValue = newValue
}
}
}
}
open var heroesClosure: (() -> [RoomHero])?
open override func heroes() -> [RoomHero] {
heroesCallsCount += 1
if let heroesClosure = heroesClosure {
return heroesClosure()
} else {
return heroesReturnValue
}
}
//MARK: - id
var idUnderlyingCallsCount = 0