mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Replace the old RoomInfoUpdateListener with the SDKListener
This commit is contained in:
committed by
Stefan Ceriu
parent
4e2e2649fc
commit
cad21daeea
@@ -50,6 +50,7 @@
|
|||||||
066A1E9B94723EE9F3038044 /* Strings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47EBB5D698CE9A25BB553A2D /* Strings.swift */; };
|
066A1E9B94723EE9F3038044 /* Strings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47EBB5D698CE9A25BB553A2D /* Strings.swift */; };
|
||||||
06B31F84CE52A7A7C271267C /* SecureBackupRecoveryKeyScreenViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0FF08D0BD7D0B4B6877AB7D /* SecureBackupRecoveryKeyScreenViewModelTests.swift */; };
|
06B31F84CE52A7A7C271267C /* SecureBackupRecoveryKeyScreenViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0FF08D0BD7D0B4B6877AB7D /* SecureBackupRecoveryKeyScreenViewModelTests.swift */; };
|
||||||
06B55882911B4BF5B14E9851 /* URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 227AC5D71A4CE43512062243 /* URL.swift */; };
|
06B55882911B4BF5B14E9851 /* URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 227AC5D71A4CE43512062243 /* URL.swift */; };
|
||||||
|
06D17F7813AA931FF18FD5D0 /* SDKListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE5CD2993048222B64C45006 /* SDKListener.swift */; };
|
||||||
06D3942496E9E0E655F14D21 /* NotificationManagerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = A057F2FDC14866C3026A89A4 /* NotificationManagerProtocol.swift */; };
|
06D3942496E9E0E655F14D21 /* NotificationManagerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = A057F2FDC14866C3026A89A4 /* NotificationManagerProtocol.swift */; };
|
||||||
06F8EDF52E33A2D36BCC1161 /* AppLockScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56D6F88FE35A0979D2821E06 /* AppLockScreen.swift */; };
|
06F8EDF52E33A2D36BCC1161 /* AppLockScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56D6F88FE35A0979D2821E06 /* AppLockScreen.swift */; };
|
||||||
071A017E415AD378F2961B11 /* URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 227AC5D71A4CE43512062243 /* URL.swift */; };
|
071A017E415AD378F2961B11 /* URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 227AC5D71A4CE43512062243 /* URL.swift */; };
|
||||||
@@ -6725,6 +6726,7 @@
|
|||||||
76C874243A8C440D6CF7B344 /* ProcessInfo.swift in Sources */,
|
76C874243A8C440D6CF7B344 /* ProcessInfo.swift in Sources */,
|
||||||
414F50CFCFEEE2611127DCFB /* RestorationToken.swift in Sources */,
|
414F50CFCFEEE2611127DCFB /* RestorationToken.swift in Sources */,
|
||||||
17BC15DA08A52587466698C5 /* RoomMessageEventStringBuilder.swift in Sources */,
|
17BC15DA08A52587466698C5 /* RoomMessageEventStringBuilder.swift in Sources */,
|
||||||
|
06D17F7813AA931FF18FD5D0 /* SDKListener.swift in Sources */,
|
||||||
7573D682F089205F7F1D96CF /* SessionDirectories.swift in Sources */,
|
7573D682F089205F7F1D96CF /* SessionDirectories.swift in Sources */,
|
||||||
422E8D182CA688D4565CD1E1 /* String.swift in Sources */,
|
422E8D182CA688D4565CD1E1 /* String.swift in Sources */,
|
||||||
6EC7A40A537CFB3D526A111C /* Strings.swift in Sources */,
|
6EC7A40A537CFB3D526A111C /* Strings.swift in Sources */,
|
||||||
|
|||||||
@@ -74,6 +74,12 @@ extension SDKListener: RoomListLoadingStateListener where T == RoomListLoadingSt
|
|||||||
func onUpdate(state: RoomListLoadingState) { onUpdateClosure(state) }
|
func onUpdate(state: RoomListLoadingState) { onUpdateClosure(state) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: Room
|
||||||
|
|
||||||
|
extension SDKListener: RoomInfoListener where T == RoomInfo {
|
||||||
|
func call(roomInfo: RoomInfo) { onUpdateClosure(roomInfo) }
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: TimelineProxy
|
// MARK: TimelineProxy
|
||||||
|
|
||||||
extension SDKListener: PaginationStatusListener where T == RoomPaginationStatus {
|
extension SDKListener: PaginationStatusListener where T == RoomPaginationStatus {
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
roomInfoObservationToken = room.subscribeToRoomInfoUpdates(listener: RoomInfoUpdateListener { [weak self] roomInfo in
|
roomInfoObservationToken = room.subscribeToRoomInfoUpdates(listener: SDKListener { [weak self] roomInfo in
|
||||||
MXLog.info("Received room info update")
|
MXLog.info("Received room info update")
|
||||||
self?.infoSubject.send(.init(roomInfo: roomInfo))
|
self?.infoSubject.send(.init(roomInfo: roomInfo))
|
||||||
})
|
})
|
||||||
@@ -810,18 +810,6 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class RoomInfoUpdateListener: RoomInfoListener {
|
|
||||||
private let onUpdateClosure: (RoomInfo) -> Void
|
|
||||||
|
|
||||||
init(_ onUpdateClosure: @escaping (RoomInfo) -> Void) {
|
|
||||||
self.onUpdateClosure = onUpdateClosure
|
|
||||||
}
|
|
||||||
|
|
||||||
func call(roomInfo: RoomInfo) {
|
|
||||||
onUpdateClosure(roomInfo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final class RoomTypingNotificationUpdateListener: TypingNotificationsListener {
|
private final class RoomTypingNotificationUpdateListener: TypingNotificationsListener {
|
||||||
private let onUpdateClosure: ([String]) -> Void
|
private let onUpdateClosure: ([String]) -> Void
|
||||||
|
|
||||||
|
|||||||
@@ -170,18 +170,19 @@ class NotificationHandler {
|
|||||||
// Check to see if a call is still ongoing
|
// Check to see if a call is still ongoing
|
||||||
if let room = userSession.roomForIdentifier(roomID) { // Try to get call details from the room info
|
if let room = userSession.roomForIdentifier(roomID) { // Try to get call details from the room info
|
||||||
if !room.hasActiveRoomCall() { // If I don't have an active call wait a bit and make sure
|
if !room.hasActiveRoomCall() { // If I don't have an active call wait a bit and make sure
|
||||||
let runner = ExpiringTaskRunner {
|
let expiringTask = ExpiringTaskRunner {
|
||||||
await withCheckedContinuation { [weak self] continuation in
|
await withCheckedContinuation { [weak self] continuation in
|
||||||
self?.roomInfoObservationToken = room.subscribeToRoomInfoUpdates(listener: RoomInfoUpdateListener { _ in
|
self?.roomInfoObservationToken = room.subscribeToRoomInfoUpdates(listener: SDKListener { _ in
|
||||||
MXLog.info("Received room info update")
|
MXLog.info("Received room info update")
|
||||||
continuation.resume()
|
continuation.resume()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try? await runner.run(timeout: .seconds(5)) // Wait 5 seconds or just use whatever is available
|
try? await expiringTask.run(timeout: .seconds(5)) // Wait 5 seconds or just use whatever is available
|
||||||
|
|
||||||
guard room.hasActiveRoomCall() else {
|
guard room.hasActiveRoomCall() else {
|
||||||
|
MXLog.info("The room no longer has an ongoing call, handling as push notification")
|
||||||
return .shouldDisplay
|
return .shouldDisplay
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -214,15 +215,3 @@ class NotificationHandler {
|
|||||||
case unsupportedShouldDiscard
|
case unsupportedShouldDiscard
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class RoomInfoUpdateListener: RoomInfoListener {
|
|
||||||
private let onUpdateClosure: (RoomInfo) -> Void
|
|
||||||
|
|
||||||
init(_ onUpdateClosure: @escaping (RoomInfo) -> Void) {
|
|
||||||
self.onUpdateClosure = onUpdateClosure
|
|
||||||
}
|
|
||||||
|
|
||||||
func call(roomInfo: RoomInfo) {
|
|
||||||
onUpdateClosure(roomInfo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ targets:
|
|||||||
- path: ../../ElementX/Sources/Other/NetworkMonitor
|
- path: ../../ElementX/Sources/Other/NetworkMonitor
|
||||||
- path: ../../ElementX/Sources/Other/Pills/PillUtilities.swift
|
- path: ../../ElementX/Sources/Other/Pills/PillUtilities.swift
|
||||||
- path: ../../ElementX/Sources/Other/Pills/PlainMentionBuilder.swift
|
- path: ../../ElementX/Sources/Other/Pills/PlainMentionBuilder.swift
|
||||||
|
- path: ../../ElementX/Sources/Other/SDKListener.swift
|
||||||
- path: ../../ElementX/Sources/Other/SwiftUI/Views/PlaceholderAvatarImage.swift
|
- path: ../../ElementX/Sources/Other/SwiftUI/Views/PlaceholderAvatarImage.swift
|
||||||
- path: ../../ElementX/Sources/Other/TestablePreview.swift
|
- path: ../../ElementX/Sources/Other/TestablePreview.swift
|
||||||
- path: ../../ElementX/Sources/Other/UserAgentBuilder.swift
|
- path: ../../ElementX/Sources/Other/UserAgentBuilder.swift
|
||||||
|
|||||||
Reference in New Issue
Block a user