mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Fixes element-hq/element-meta/issues/2525 - Display a warning when a user's pinned identity changes
This commit is contained in:
@@ -58,6 +58,8 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
|
||||
private var roomInfoObservationToken: TaskHandle?
|
||||
// periphery:ignore - required for instance retention in the rust codebase
|
||||
private var typingNotificationObservationToken: TaskHandle?
|
||||
// periphery:ignore - required for instance retention in the rust codebase
|
||||
private var identityStatusChangesObservationToken: TaskHandle?
|
||||
|
||||
private var subscribedForUpdates = false
|
||||
|
||||
@@ -70,6 +72,11 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
|
||||
var typingMembersPublisher: CurrentValuePublisher<[String], Never> {
|
||||
typingMembersSubject.asCurrentValuePublisher()
|
||||
}
|
||||
|
||||
private let identityStatusChangesSubject = CurrentValueSubject<[IdentityStatusChange], Never>([])
|
||||
var identityStatusChangesPublisher: CurrentValuePublisher<[IdentityStatusChange], Never> {
|
||||
identityStatusChangesSubject.asCurrentValuePublisher()
|
||||
}
|
||||
|
||||
private let actionsSubject = PassthroughSubject<JoinedRoomProxyAction, Never>()
|
||||
var actionsPublisher: AnyPublisher<JoinedRoomProxyAction, Never> {
|
||||
@@ -193,6 +200,8 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
|
||||
|
||||
subscribeToRoomInfoUpdates()
|
||||
|
||||
subscribeToIdentityStatusChanges()
|
||||
|
||||
subscribeToTypingNotifications()
|
||||
}
|
||||
|
||||
@@ -708,6 +717,16 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
|
||||
typingMembersSubject.send(typingMembers)
|
||||
})
|
||||
}
|
||||
|
||||
private func subscribeToIdentityStatusChanges() {
|
||||
identityStatusChangesObservationToken = room.subscribeToIdentityStatusChanges(listener: RoomIdentityStatusChangeListener { [weak self] changes in
|
||||
guard let self else { return }
|
||||
|
||||
MXLog.info("Received identity status changes: \(changes)")
|
||||
|
||||
identityStatusChangesSubject.send(changes)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private final class RoomInfoUpdateListener: RoomInfoListener {
|
||||
@@ -733,3 +752,15 @@ private final class RoomTypingNotificationUpdateListener: TypingNotificationsLis
|
||||
onUpdateClosure(typingUserIds)
|
||||
}
|
||||
}
|
||||
|
||||
private final class RoomIdentityStatusChangeListener: IdentityStatusChangeListener {
|
||||
private let onUpdateClosure: ([IdentityStatusChange]) -> Void
|
||||
|
||||
init(_ onUpdateClosure: @escaping ([IdentityStatusChange]) -> Void) {
|
||||
self.onUpdateClosure = onUpdateClosure
|
||||
}
|
||||
|
||||
func call(identityStatusChange: [IdentityStatusChange]) {
|
||||
onUpdateClosure(identityStatusChange)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user