Adopt batched timeline diffs and other RustSDK changes

This commit is contained in:
Stefan Ceriu 2023-08-01 16:55:59 +03:00 committed by Stefan Ceriu
parent ebb7436927
commit 28c2490910
11 changed files with 29 additions and 28 deletions

View File

@ -17,6 +17,7 @@ included:
- Tools/Scripts/Templates
excluded:
- IntegrationTests
- ElementX/Sources/Generated
line_length:
warning: 250

View File

@ -3670,12 +3670,12 @@
path = Timeline;
sourceTree = "<group>";
};
"TEMP_1F400E96-40D6-4907-8497-57790078F40B" /* repository */ = {
"TEMP_2C2AE7A1-DD19-41AC-BCFD-C9FE3F5EC278" /* element-x-ios */ = {
isa = PBXGroup;
children = (
41553551C55AD59885840F0E /* secrets.xcconfig */,
);
path = repository;
path = "element-x-ios";
sourceTree = "<group>";
};
/* End PBXGroup section */
@ -5389,7 +5389,7 @@
repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift";
requirement = {
kind = exactVersion;
version = "1.0.103-alpha";
version = "1.0.104-alpha";
};
};
96495DD8554E2F39D3954354 /* XCRemoteSwiftPackageReference "posthog-ios" */ = {

View File

@ -11,7 +11,7 @@
{
"identity" : "compound-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vector-im/compound-ios",
"location" : "https://github.com/vector-im/compound-ios.git",
"state" : {
"revision" : "1f3eb60c4f87249d95addf84ce1aef22c2968763"
}
@ -111,8 +111,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/matrix-org/matrix-rust-components-swift",
"state" : {
"revision" : "4557f06e00179b342b4522aefa064259ec12b0d7",
"version" : "1.0.103-alpha"
"revision" : "c22c3391690abb33dbe95b28e2f522793624547c",
"version" : "1.0.104-alpha"
}
},
{

View File

@ -747,11 +747,11 @@ class RoomProxyMock: RoomProxyProtocol {
set(value) { underlyingActiveMembersCount = value }
}
var underlyingActiveMembersCount: Int!
var updatesPublisher: AnyPublisher<TimelineDiff, Never> {
var updatesPublisher: AnyPublisher<[TimelineDiff], Never> {
get { return underlyingUpdatesPublisher }
set(value) { underlyingUpdatesPublisher = value }
}
var underlyingUpdatesPublisher: AnyPublisher<TimelineDiff, Never>!
var underlyingUpdatesPublisher: AnyPublisher<[TimelineDiff], Never>!
var timelineProvider: RoomTimelineProviderProtocol {
get { return underlyingTimelineProvider }
set(value) { underlyingTimelineProvider = value }

View File

@ -27,7 +27,7 @@ struct InvitesScreenCell: View {
var body: some View {
HStack(alignment: .top, spacing: 16) {
LoadableAvatarImage(url: mainAvatarURL,
LoadableAvatarImage(url: invite.roomDetails.avatarURL,
name: title,
contentID: invite.roomDetails.id,
avatarSize: .custom(52),
@ -119,12 +119,7 @@ struct InvitesScreenCell: View {
.fill(Color.compound.borderDisabled)
.frame(height: 1 / UIScreen.main.scale)
}
#warning("Return just `roomDetails.avatarURL` when this logic is implemented in the rust sdk")
private var mainAvatarURL: URL? {
invite.isDirect ? invite.inviter?.avatarURL : invite.roomDetails.avatarURL
}
private var title: String {
invite.roomDetails.name
}

View File

@ -88,7 +88,12 @@ struct NotificationItemProxy: NotificationItemProxyProtocol {
}
var senderID: String {
notificationItem.senderInfo.userId
switch notificationItem.event {
case .timeline(let event):
return event.senderId()
case .invite(let senderID):
return senderID
}
}
var roomDisplayName: String {

View File

@ -45,8 +45,8 @@ class RoomProxy: RoomProxyProtocol {
}
private var timelineListener: RoomTimelineListener?
private let updatesSubject = PassthroughSubject<TimelineDiff, Never>()
var updatesPublisher: AnyPublisher<TimelineDiff, Never> {
private let updatesSubject = PassthroughSubject<[TimelineDiff], Never>()
var updatesPublisher: AnyPublisher<[TimelineDiff], Never> {
updatesSubject.eraseToAnyPublisher()
}
@ -80,8 +80,8 @@ class RoomProxy: RoomProxyProtocol {
timelineLimit: UInt32(SlidingSyncConstants.defaultTimelineLimit))
roomListItem.subscribe(settings: settings)
let timelineListener = RoomTimelineListener { [weak self] timelineDiff in
self?.updatesSubject.send(timelineDiff)
let timelineListener = RoomTimelineListener { [weak self] timelineDiffs in
self?.updatesSubject.send(timelineDiffs)
}
self.timelineListener = timelineListener
@ -691,13 +691,13 @@ class RoomProxy: RoomProxyProtocol {
}
private final class RoomTimelineListener: TimelineListener {
private let onUpdateClosure: (TimelineDiff) -> Void
private let onUpdateClosure: ([TimelineDiff]) -> Void
init(_ onUpdateClosure: @escaping (TimelineDiff) -> Void) {
init(_ onUpdateClosure: @escaping ([TimelineDiff]) -> Void) {
self.onUpdateClosure = onUpdateClosure
}
func onUpdate(diff: TimelineDiff) {
func onUpdate(diff: [TimelineDiff]) {
onUpdateClosure(diff)
}
}

View File

@ -74,7 +74,7 @@ protocol RoomProxyProtocol {
/// Publishes the room's updates.
/// The thread on which this publisher sends the output isn't defined.
var updatesPublisher: AnyPublisher<TimelineDiff, Never> { get }
var updatesPublisher: AnyPublisher<[TimelineDiff], Never> { get }
var timelineProvider: RoomTimelineProviderProtocol { get }

View File

@ -40,7 +40,7 @@ class RoomTimelineProvider: RoomTimelineProviderProtocol {
}
init(currentItems: [TimelineItem],
updatePublisher: AnyPublisher<TimelineDiff, Never>,
updatePublisher: AnyPublisher<[TimelineDiff], Never>,
backPaginationStatePublisher: AnyPublisher<BackPaginationStatus, Never>) {
serialDispatchQueue = DispatchQueue(label: "io.element.elementx.roomtimelineprovider", qos: .utility)
itemProxiesSubject = CurrentValueSubject<[TimelineItemProxy], Never>(currentItems.map(TimelineItemProxy.init))
@ -49,7 +49,7 @@ class RoomTimelineProvider: RoomTimelineProviderProtocol {
itemProxiesSubject.send(itemProxies)
updatePublisher
.collect(.byTime(serialDispatchQueue, 0.1))
.receive(on: serialDispatchQueue)
.sink { [weak self] in self?.updateItemsWithDiffs($0) }
.store(in: &cancellables)

View File

@ -48,7 +48,7 @@ final class NSEUserSession {
func notificationItemProxy(roomID: String, eventID: String) async -> NotificationItemProxyProtocol? {
await Task.dispatch(on: .global()) {
do {
let notification = try self.notificationClient.getNotificationWithSlidingSync(roomId: roomID, eventId: eventID)
let notification = try self.notificationClient.getNotification(roomId: roomID, eventId: eventID)
guard let notification else {
return nil

View File

@ -45,7 +45,7 @@ include:
packages:
MatrixRustSDK:
url: https://github.com/matrix-org/matrix-rust-components-swift
exactVersion: 1.0.103-alpha
exactVersion: 1.0.104-alpha
# path: ../matrix-rust-sdk
DesignKit:
path: DesignKit