Skip to content

Commit

Permalink
Adopt the changes introduced in matrix-org/matrix-rust-sdk/pull/4159
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Oct 23, 2024
1 parent a4ea552 commit 8f9f8cb
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 251 deletions.
2 changes: 1 addition & 1 deletion ElementX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7822,7 +7822,7 @@
repositoryURL = "https://github.com/element-hq/matrix-rust-components-swift";
requirement = {
kind = exactVersion;
version = 1.0.59;
version = 1.0.60;
};
};
701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/element-hq/matrix-rust-components-swift",
"state" : {
"revision" : "acd36f68f107f608c33b4d5b46be4ddea5537b1f",
"version" : "1.0.59"
"revision" : "dc3a2199b0e87824ccf06d1207487d2e49c5e584",
"version" : "1.0.60"
}
},
{
Expand Down
351 changes: 138 additions & 213 deletions ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions ElementX/Sources/Services/Client/ClientProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ class ClientProxy: ClientProxyProtocol {

func knockRoom(_ roomID: String, message: String?) async -> Result<Void, ClientProxyError> {
do {
// TODO: It should also include a message but the API for is not available yet
let _ = try await client.knock(roomIdOrAlias: roomID)
await waitForRoomToSync(roomID: roomID, timeout: .seconds(30))
return .success(())
Expand All @@ -429,7 +428,6 @@ class ClientProxy: ClientProxyProtocol {

func knockRoomAlias(_ roomAlias: String, message: String?) async -> Result<Void, ClientProxyError> {
do {
// TODO: It should also include a message but the API for is not available yet
let room = try await client.knock(roomIdOrAlias: roomAlias)
await waitForRoomToSync(roomID: room.id(), timeout: .seconds(30))
return .success(())
Expand Down
9 changes: 0 additions & 9 deletions ElementX/Sources/Services/Client/ClientProxyProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,7 @@ enum ClientProxyError: Error {
}

enum SlidingSyncConstants {
static let defaultTimelineLimit: UInt32 = 20
static let maximumVisibleRangeSize = 30
static let defaultRequiredState = [
RequiredState(key: "m.room.name", value: ""),
RequiredState(key: "m.room.topic", value: ""),
RequiredState(key: "m.room.avatar", value: ""),
RequiredState(key: "m.room.canonical_alias", value: ""),
RequiredState(key: "m.room.join_rules", value: ""),
RequiredState(key: "m.room.pinned_events", value: "")
]
}

/// This struct represents the configuration that we are using to register the application through Pusher to Sygnal
Expand Down
6 changes: 2 additions & 4 deletions ElementX/Sources/Services/Room/JoinedRoomProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,9 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
}

subscribedForUpdates = true
let settings = RoomSubscription(requiredState: SlidingSyncConstants.defaultRequiredState,
timelineLimit: SlidingSyncConstants.defaultTimelineLimit,
includeHeroes: false) // We don't need heroes here as they're already included in the `all_rooms` list

do {
try roomListService.subscribeToRooms(roomIds: [id], settings: settings)
try roomListService.subscribeToRooms(roomIds: [id])
} catch {
MXLog.error("Failed subscribing to room with error: \(error)")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
guard let self else { return }

do {
try roomListService.subscribeToRooms(roomIds: roomIDs,
settings: .init(requiredState: SlidingSyncConstants.defaultRequiredState,
timelineLimit: SlidingSyncConstants.defaultTimelineLimit,
includeHeroes: false))
try roomListService.subscribeToRooms(roomIds: roomIDs)
} catch {
MXLog.error("Failed subscribing to rooms with error: \(error)")
}
Expand Down
56 changes: 41 additions & 15 deletions ElementX/Sources/Services/Timeline/TimelineProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,14 @@ final class TimelineProxy: TimelineProxyProtocol {
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError> {
MXLog.info("Sending audio")

let handle = timeline.sendAudio(url: url.path(percentEncoded: false), audioInfo: audioInfo, caption: nil, formattedCaption: nil, progressWatcher: UploadProgressListener { progress in
progressSubject?.send(progress)
})
let handle = timeline.sendAudio(url: url.path(percentEncoded: false),
audioInfo: audioInfo,
caption: nil,
formattedCaption: nil,
storeInCache: true,
progressWatcher: UploadProgressListener { progress in
progressSubject?.send(progress)
})

await requestHandle(handle)

Expand All @@ -250,9 +255,12 @@ final class TimelineProxy: TimelineProxyProtocol {
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError> {
MXLog.info("Sending file")

let handle = timeline.sendFile(url: url.path(percentEncoded: false), fileInfo: fileInfo, progressWatcher: UploadProgressListener { progress in
progressSubject?.send(progress)
})
let handle = timeline.sendFile(url: url.path(percentEncoded: false),
fileInfo: fileInfo,
storeInCache: true,
progressWatcher: UploadProgressListener { progress in
progressSubject?.send(progress)
})

await requestHandle(handle)

Expand All @@ -274,9 +282,15 @@ final class TimelineProxy: TimelineProxyProtocol {
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError> {
MXLog.info("Sending image")

let handle = timeline.sendImage(url: url.path(percentEncoded: false), thumbnailUrl: thumbnailURL.path(percentEncoded: false), imageInfo: imageInfo, caption: nil, formattedCaption: nil, progressWatcher: UploadProgressListener { progress in
progressSubject?.send(progress)
})
let handle = timeline.sendImage(url: url.path(percentEncoded: false),
thumbnailUrl: thumbnailURL.path(percentEncoded: false),
imageInfo: imageInfo,
caption: nil,
formattedCaption: nil,
storeInCache: true,
progressWatcher: UploadProgressListener { progress in
progressSubject?.send(progress)
})

await requestHandle(handle)

Expand Down Expand Up @@ -316,9 +330,15 @@ final class TimelineProxy: TimelineProxyProtocol {
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError> {
MXLog.info("Sending video")

let handle = timeline.sendVideo(url: url.path(percentEncoded: false), thumbnailUrl: thumbnailURL.path(percentEncoded: false), videoInfo: videoInfo, caption: nil, formattedCaption: nil, progressWatcher: UploadProgressListener { progress in
progressSubject?.send(progress)
})
let handle = timeline.sendVideo(url: url.path(percentEncoded: false),
thumbnailUrl: thumbnailURL.path(percentEncoded: false),
videoInfo: videoInfo,
caption: nil,
formattedCaption: nil,
storeInCache: true,
progressWatcher: UploadProgressListener { progress in
progressSubject?.send(progress)
})

await requestHandle(handle)

Expand All @@ -340,9 +360,15 @@ final class TimelineProxy: TimelineProxyProtocol {
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError> {
MXLog.info("Sending voice message")

let handle = timeline.sendVoiceMessage(url: url.path(percentEncoded: false), audioInfo: audioInfo, waveform: waveform, caption: nil, formattedCaption: nil, progressWatcher: UploadProgressListener { progress in
progressSubject?.send(progress)
})
let handle = timeline.sendVoiceMessage(url: url.path(percentEncoded: false),
audioInfo: audioInfo,
waveform: waveform,
caption: nil,
formattedCaption: nil,
storeInCache: true,
progressWatcher: UploadProgressListener { progress in
progressSubject?.send(progress)
})

await requestHandle(handle)

Expand Down
2 changes: 1 addition & 1 deletion project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ packages:
# Element/Matrix dependencies
MatrixRustSDK:
url: https://github.com/element-hq/matrix-rust-components-swift
exactVersion: 1.0.59
exactVersion: 1.0.60
# path: ../matrix-rust-sdk
Compound:
url: https://github.com/element-hq/compound-ios
Expand Down

0 comments on commit 8f9f8cb

Please sign in to comment.