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:
Stefan Ceriu
2025-04-01 09:45:53 +03:00
committed by Stefan Ceriu
parent 5e50823223
commit 901c833c40
16 changed files with 130 additions and 88 deletions
@@ -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)
}
}