Update the SDK fixing a few room list bugs. (#3054)

* Update the SDK.

* Handle API break for editing timeline items.

* Handle API break for Element Call
This commit is contained in:
Doug
2024-07-17 15:48:32 +01:00
committed by GitHub
parent aa71f10b40
commit 95d53f1edf
12 changed files with 163 additions and 100 deletions
@@ -39,6 +39,7 @@ private struct ElementCallWidgetMessage: Codable {
class ElementCallWidgetDriver: WidgetCapabilitiesProvider, ElementCallWidgetDriverProtocol {
private let room: RoomProtocol
private let deviceID: String
private var widgetDriver: WidgetDriverAndHandle?
let widgetID = UUID().uuidString
@@ -49,8 +50,9 @@ class ElementCallWidgetDriver: WidgetCapabilitiesProvider, ElementCallWidgetDriv
actionsSubject.eraseToAnyPublisher()
}
init(room: RoomProtocol) {
init(room: RoomProtocol, deviceID: String) {
self.room = room
self.deviceID = deviceID
}
func start(baseURL: URL, clientID: String, colorScheme: ColorScheme) async -> Result<URL, ElementCallWidgetDriverError> {
@@ -143,7 +145,7 @@ class ElementCallWidgetDriver: WidgetCapabilitiesProvider, ElementCallWidgetDriv
// MARK: - WidgetCapabilitiesProvider
func acquireCapabilities(capabilities: WidgetCapabilities) -> WidgetCapabilities {
getElementCallRequiredPermissions(ownUserId: room.ownUserId())
getElementCallRequiredPermissions(ownUserId: room.ownUserId(), ownDeviceId: deviceID)
}
// MARK: - Private
@@ -526,8 +526,8 @@ class RoomProxy: RoomProxyProtocol {
}
}
func elementCallWidgetDriver() -> ElementCallWidgetDriverProtocol {
ElementCallWidgetDriver(room: room)
func elementCallWidgetDriver(deviceID: String) -> ElementCallWidgetDriverProtocol {
ElementCallWidgetDriver(room: room, deviceID: deviceID)
}
func sendCallNotificationIfNeeeded() async -> Result<Void, RoomProxyError> {
@@ -129,7 +129,7 @@ protocol RoomProxyProtocol {
// MARK: - Element Call
func canUserJoinCall(userID: String) async -> Result<Bool, RoomProxyError>
func elementCallWidgetDriver() -> ElementCallWidgetDriverProtocol
func elementCallWidgetDriver(deviceID: String) -> ElementCallWidgetDriverProtocol
func sendCallNotificationIfNeeeded() async -> Result<Void, RoomProxyError>
@@ -158,12 +158,7 @@ final class TimelineProxy: TimelineProxyProtocol {
intentionalMentions: IntentionalMentions) async -> Result<Void, TimelineProxyError> {
MXLog.info("Editing timeline item: \(timelineItemID)")
let editMode: EditMode
if let eventID = timelineItemID.eventID {
editMode = .remote(eventID: eventID)
} else if let eventTimelineItem = await timelineProvider.itemProxies.firstEventTimelineItemUsingID(timelineItemID) {
editMode = .local(item: eventTimelineItem)
} else {
guard let timelineItem = await timelineProvider.itemProxies.firstEventTimelineItemUsingID(timelineItemID) else {
MXLog.error("Unknown timeline item: \(timelineItemID)")
return .failure(.failedEditing)
}
@@ -173,13 +168,8 @@ final class TimelineProxy: TimelineProxyProtocol {
intentionalMentions: intentionalMentions.toRustMentions())
do {
switch editMode {
case let .local(item):
guard try await timeline.edit(item: item, newContent: messageContent) == true else {
return .failure(.failedEditing)
}
case let .remote(eventID):
try await timeline.editByEventId(eventId: eventID, newContent: messageContent)
guard try await timeline.edit(item: timelineItem, newContent: messageContent) == true else {
return .failure(.failedEditing)
}
MXLog.info("Finished editing timeline item: \(timelineItemID)")
@@ -625,11 +615,3 @@ extension Array where Element == TimelineItemProxy {
return eventTimelineItemProxy?.item
}
}
private enum EditMode {
/// edit for a message that is also found locally as a timeline item
case local(item: EventTimelineItem)
/// edit for a message that was not found locally
case remote(eventID: String)
}