mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 11:58:32 +00:00
Bump the RustSDK to v25.03.31
- adopt new async throwing methods - use the sdk side TimelineStart virtual timeline item - remove async from `directRoomForUserID` as it's not async on the rust side - remove async from `retryDecryption` as it's spawning not blocking on the rust side
This commit is contained in:
committed by
Stefan Ceriu
parent
5e50823223
commit
901c833c40
@@ -353,15 +353,13 @@ class ClientProxy: ClientProxyProtocol {
|
||||
try? await client.accountUrl(action: action).flatMap(URL.init(string:))
|
||||
}
|
||||
|
||||
func directRoomForUserID(_ userID: String) async -> Result<String?, ClientProxyError> {
|
||||
await Task.dispatch(on: clientQueue) {
|
||||
do {
|
||||
let roomID = try self.client.getDmRoom(userId: userID)?.id()
|
||||
return .success(roomID)
|
||||
} catch {
|
||||
MXLog.error("Failed retrieving direct room for userID: \(userID) with error: \(error)")
|
||||
return .failure(.sdkError(error))
|
||||
}
|
||||
func directRoomForUserID(_ userID: String) -> Result<String?, ClientProxyError> {
|
||||
do {
|
||||
let roomID = try client.getDmRoom(userId: userID)?.id()
|
||||
return .success(roomID)
|
||||
} catch {
|
||||
MXLog.error("Failed retrieving direct room for userID: \(userID) with error: \(error)")
|
||||
return .failure(.sdkError(error))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol {
|
||||
|
||||
func accountURL(action: AccountManagementAction) async -> URL?
|
||||
|
||||
func directRoomForUserID(_ userID: String) async -> Result<String?, ClientProxyError>
|
||||
func directRoomForUserID(_ userID: String) -> Result<String?, ClientProxyError>
|
||||
|
||||
func createDirectRoom(with userID: String, expectedRoomName: String?) async -> Result<String, ClientProxyError>
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
|
||||
await subscribeToKnockRequests()
|
||||
|
||||
if infoPublisher.value.isEncrypted {
|
||||
subscribeToIdentityStatusChanges()
|
||||
await subscribeToIdentityStatusChanges()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -763,14 +763,18 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
|
||||
})
|
||||
}
|
||||
|
||||
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 func subscribeToIdentityStatusChanges() async {
|
||||
do {
|
||||
identityStatusChangesObservationToken = try await room.subscribeToIdentityStatusChanges(listener: RoomIdentityStatusChangeListener { [weak self] changes in
|
||||
guard let self else { return }
|
||||
|
||||
MXLog.info("Received identity status changes: \(changes)")
|
||||
|
||||
identityStatusChangesSubject.send(changes)
|
||||
})
|
||||
} catch {
|
||||
MXLog.error("Failed subscribing to identity status changes with error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
private func subscribeToKnockRequests() async {
|
||||
|
||||
@@ -392,6 +392,7 @@ class TimelineController: TimelineControllerProtocol {
|
||||
isSwitchingTimelines = false
|
||||
|
||||
let isDM = roomProxy.isDirectOneToOneRoom
|
||||
let displayName = roomProxy.infoPublisher.value.displayName
|
||||
|
||||
var newTimelineItems = await Task.detached { [timelineItemFactory, activeTimeline] in
|
||||
var newTimelineItems = [RoomTimelineItemProtocol]()
|
||||
@@ -404,6 +405,7 @@ class TimelineController: TimelineControllerProtocol {
|
||||
let items = collapsibleChunk.compactMap { itemProxy in
|
||||
let timelineItem = self.buildTimelineItem(for: itemProxy,
|
||||
isDM: isDM,
|
||||
roomDisplayName: displayName,
|
||||
timelineItemFactory: timelineItemFactory,
|
||||
activeTimeline: activeTimeline)
|
||||
|
||||
@@ -432,14 +434,9 @@ class TimelineController: TimelineControllerProtocol {
|
||||
|
||||
// Check if we need to add anything to the top of the timeline.
|
||||
switch paginationState.backward {
|
||||
case .timelineEndReached:
|
||||
if timelineKind != .pinned, !roomProxy.isDirectOneToOneRoom {
|
||||
let timelineStart = TimelineStartRoomTimelineItem(name: roomProxy.infoPublisher.value.displayName)
|
||||
newTimelineItems.insert(timelineStart, at: 0)
|
||||
}
|
||||
case .paginating:
|
||||
newTimelineItems.insert(PaginationIndicatorRoomTimelineItem(position: .start), at: 0)
|
||||
case .idle:
|
||||
case .idle, .timelineEndReached:
|
||||
break
|
||||
}
|
||||
|
||||
@@ -458,6 +455,7 @@ class TimelineController: TimelineControllerProtocol {
|
||||
|
||||
private nonisolated func buildTimelineItem(for itemProxy: TimelineItemProxy,
|
||||
isDM: Bool,
|
||||
roomDisplayName: String?,
|
||||
timelineItemFactory: RoomTimelineItemFactoryProtocol,
|
||||
activeTimeline: TimelineProxyProtocol) -> RoomTimelineItemProtocol? {
|
||||
switch itemProxy {
|
||||
@@ -480,6 +478,8 @@ class TimelineController: TimelineControllerProtocol {
|
||||
return SeparatorRoomTimelineItem(id: .virtual(uniqueID: uniqueID), timestamp: date)
|
||||
case .readMarker:
|
||||
return ReadMarkerRoomTimelineItem(id: .virtual(uniqueID: uniqueID))
|
||||
case .timelineStart:
|
||||
return isDM ? nil : TimelineStartRoomTimelineItem(name: roomDisplayName)
|
||||
}
|
||||
case .unknown:
|
||||
return nil
|
||||
|
||||
@@ -209,6 +209,8 @@ private extension VirtualTimelineItem {
|
||||
return "DayDiviver(\(timestamp))"
|
||||
case .readMarker:
|
||||
return "ReadMarker"
|
||||
case .timelineStart:
|
||||
return "TimelineStart"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,15 +159,13 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func retryDecryption(sessionIDs: [String]?) async {
|
||||
func retryDecryption(sessionIDs: [String]?) {
|
||||
let sessionIDs = sessionIDs ?? []
|
||||
|
||||
MXLog.info("Retrying decryption for sessionIDs: \(sessionIDs)")
|
||||
|
||||
await Task.dispatch(on: .global()) { [weak self] in
|
||||
self?.timeline.retryDecryption(sessionIds: sessionIDs)
|
||||
MXLog.info("Finished retrying decryption for sessionID: \(sessionIDs)")
|
||||
}
|
||||
timeline.retryDecryption(sessionIds: sessionIDs)
|
||||
MXLog.info("Finished retrying decryption for sessionID: \(sessionIDs)")
|
||||
}
|
||||
|
||||
func edit(_ eventOrTransactionID: TimelineItemIdentifier.EventOrTransactionID, newContent: EditedContent) async -> Result<Void, TimelineProxyError> {
|
||||
@@ -504,17 +502,15 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
func endPoll(pollStartID: String, text: String) async -> Result<Void, TimelineProxyError> {
|
||||
MXLog.info("Ending poll with eventID: \(pollStartID)")
|
||||
|
||||
return await Task.dispatch(on: .global()) {
|
||||
do {
|
||||
try self.timeline.endPoll(pollStartEventId: pollStartID, text: text)
|
||||
|
||||
MXLog.info("Finished ending poll with eventID: \(pollStartID)")
|
||||
|
||||
return .success(())
|
||||
} catch {
|
||||
MXLog.error("Failed ending poll with eventID: \(pollStartID) with error: \(error)")
|
||||
return .failure(.sdkError(error))
|
||||
}
|
||||
do {
|
||||
try await timeline.endPoll(pollStartEventId: pollStartID, text: text)
|
||||
|
||||
MXLog.info("Finished ending poll with eventID: \(pollStartID)")
|
||||
|
||||
return .success(())
|
||||
} catch {
|
||||
MXLog.error("Failed ending poll with eventID: \(pollStartID) with error: \(error)")
|
||||
return .failure(.sdkError(error))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ protocol TimelineProxyProtocol {
|
||||
|
||||
func messageEventContent(for timelineItemID: TimelineItemIdentifier) async -> RoomMessageEventContentWithoutRelation?
|
||||
|
||||
func retryDecryption(sessionIDs: [String]?) async
|
||||
func retryDecryption(sessionIDs: [String]?)
|
||||
|
||||
func paginateBackwards(requestSize: UInt16) async -> Result<Void, TimelineProxyError>
|
||||
func paginateForwards(requestSize: UInt16) async -> Result<Void, TimelineProxyError>
|
||||
@@ -123,9 +123,3 @@ protocol TimelineProxyProtocol {
|
||||
html: String?,
|
||||
intentionalMentions: Mentions) -> RoomMessageEventContentWithoutRelation
|
||||
}
|
||||
|
||||
extension TimelineProxyProtocol {
|
||||
func retryDecryption() async {
|
||||
await retryDecryption(sessionIDs: nil)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user