mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 19:44:05 +00:00
Revert "Adopt async uniffi in the RoomSummaryProvider and ensure diffs are still processed serially"
This reverts commit d710dafc94.
This commit is contained in:
committed by
Stefan Ceriu
parent
b238e3efdd
commit
524997438f
@@ -109,19 +109,6 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
|||||||
|
|
||||||
MXLog.info("\(name): Finished applying \(diffs.count) diffs, new room list \(rooms.compactMap { $0.id ?? "Empty" })")
|
MXLog.info("\(name): Finished applying \(diffs.count) diffs, new room list \(rooms.compactMap { $0.id ?? "Empty" })")
|
||||||
}
|
}
|
||||||
|
|
||||||
// The room summary provider needs to process diffs serially
|
|
||||||
// Switching to an actor here doesn't help because of all the suspension points
|
|
||||||
// and actor re-entrance
|
|
||||||
private static var latestRoomMessage: EventTimelineItem?
|
|
||||||
private func fetchLastMessage(room: SlidingSyncRoomProtocol) {
|
|
||||||
let semaphore = DispatchSemaphore(value: 0)
|
|
||||||
Task {
|
|
||||||
Self.latestRoomMessage = await room.latestRoomMessage()
|
|
||||||
semaphore.signal()
|
|
||||||
}
|
|
||||||
semaphore.wait()
|
|
||||||
}
|
|
||||||
|
|
||||||
private func buildRoomSummaryForIdentifier(_ identifier: String, invalidated: Bool) -> RoomSummary {
|
private func buildRoomSummaryForIdentifier(_ identifier: String, invalidated: Bool) -> RoomSummary {
|
||||||
guard let room = try? slidingSyncListProxy.roomForIdentifier(identifier) else {
|
guard let room = try? slidingSyncListProxy.roomForIdentifier(identifier) else {
|
||||||
@@ -132,12 +119,14 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
|||||||
var attributedLastMessage: AttributedString?
|
var attributedLastMessage: AttributedString?
|
||||||
var lastMessageFormattedTimestamp: String?
|
var lastMessageFormattedTimestamp: String?
|
||||||
|
|
||||||
fetchLastMessage(room: room)
|
// Dispatch onto another queue otherwise the rust method latestRoomMessage crashes.
|
||||||
|
// This will be fixed when we get async uniffi support.
|
||||||
if let latestRoomMessage = Self.latestRoomMessage {
|
DispatchQueue.global(qos: .userInitiated).sync {
|
||||||
let lastMessage = EventTimelineItemProxy(item: latestRoomMessage)
|
if let latestRoomMessage = room.latestRoomMessage() {
|
||||||
lastMessageFormattedTimestamp = lastMessage.timestamp.formattedMinimal()
|
let lastMessage = EventTimelineItemProxy(item: latestRoomMessage)
|
||||||
attributedLastMessage = eventStringBuilder.buildAttributedString(for: lastMessage)
|
lastMessageFormattedTimestamp = lastMessage.timestamp.formattedMinimal()
|
||||||
|
attributedLastMessage = eventStringBuilder.buildAttributedString(for: lastMessage)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let fullRoom = room.fullRoom()
|
let fullRoom = room.fullRoom()
|
||||||
|
|||||||
Reference in New Issue
Block a user