Browse Source

Merge pull request #757 from vector-im/feature/fga/update-rust-sdk-0.1.27

Update rust sdk to 0.1.27
julioromano/fixTallAndWidePreviews
ganfra 1 year ago committed by GitHub
parent
commit
0831f87713
  1. 2
      gradle/libs.versions.toml
  2. 35
      libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt

2
gradle/libs.versions.toml

@ -142,7 +142,7 @@ jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" } @@ -142,7 +142,7 @@ jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" }
appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" }
molecule-runtime = { module = "app.cash.molecule:molecule-runtime", version.ref = "molecule" }
timber = "com.jakewharton.timber:timber:5.0.1"
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.1.26"
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.1.27"
sqldelight-driver-android = { module = "com.squareup.sqldelight:android-driver", version.ref = "sqldelight" }
sqldelight-driver-jvm = { module = "com.squareup.sqldelight:sqlite-driver", version.ref = "sqldelight" }
sqldelight-coroutines = { module = "com.squareup.sqldelight:coroutines-extensions", version.ref = "sqldelight" }

35
libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt

@ -41,7 +41,6 @@ import io.element.android.libraries.matrix.impl.timeline.timelineDiffFlow @@ -41,7 +41,6 @@ import io.element.android.libraries.matrix.impl.timeline.timelineDiffFlow
import io.element.android.services.toolbox.api.systemclock.SystemClock
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
@ -54,6 +53,7 @@ import org.matrix.rustcomponents.sdk.Room @@ -54,6 +53,7 @@ import org.matrix.rustcomponents.sdk.Room
import org.matrix.rustcomponents.sdk.RoomListItem
import org.matrix.rustcomponents.sdk.RoomMember
import org.matrix.rustcomponents.sdk.RoomSubscription
import org.matrix.rustcomponents.sdk.SendAttachmentJoinHandle
import org.matrix.rustcomponents.sdk.genTransactionId
import org.matrix.rustcomponents.sdk.messageEventContentFromMarkdown
import timber.log.Timber
@ -272,30 +272,26 @@ class RustMatrixRoom( @@ -272,30 +272,26 @@ class RustMatrixRoom(
}
}
override suspend fun sendImage(file: File, thumbnailFile: File, imageInfo: ImageInfo, progressCallback: ProgressCallback?): Result<Unit> = withContext(
coroutineDispatchers.io
) {
runCatching {
override suspend fun sendImage(file: File, thumbnailFile: File, imageInfo: ImageInfo, progressCallback: ProgressCallback?): Result<Unit> {
return sendAttachment {
innerRoom.sendImage(file.path, thumbnailFile.path, imageInfo.map(), progressCallback?.toProgressWatcher())
}
}
override suspend fun sendVideo(file: File, thumbnailFile: File, videoInfo: VideoInfo, progressCallback: ProgressCallback?): Result<Unit> = withContext(
coroutineDispatchers.io
) {
runCatching {
override suspend fun sendVideo(file: File, thumbnailFile: File, videoInfo: VideoInfo, progressCallback: ProgressCallback?): Result<Unit> {
return sendAttachment {
innerRoom.sendVideo(file.path, thumbnailFile.path, videoInfo.map(), progressCallback?.toProgressWatcher())
}
}
override suspend fun sendAudio(file: File, audioInfo: AudioInfo, progressCallback: ProgressCallback?): Result<Unit> = withContext(coroutineDispatchers.io) {
runCatching {
override suspend fun sendAudio(file: File, audioInfo: AudioInfo, progressCallback: ProgressCallback?): Result<Unit> {
return sendAttachment {
innerRoom.sendAudio(file.path, audioInfo.map(), progressCallback?.toProgressWatcher())
}
}
override suspend fun sendFile(file: File, fileInfo: FileInfo, progressCallback: ProgressCallback?): Result<Unit> = withContext(coroutineDispatchers.io) {
runCatching {
override suspend fun sendFile(file: File, fileInfo: FileInfo, progressCallback: ProgressCallback?): Result<Unit> {
return sendAttachment {
innerRoom.sendFile(file.path, fileInfo.map(), progressCallback?.toProgressWatcher())
}
}
@ -372,12 +368,23 @@ class RustMatrixRoom( @@ -372,12 +368,23 @@ class RustMatrixRoom(
}
}
//TODO expose inner parameters
override suspend fun sendLocation(
body: String,
geoUri: String
): Result<Unit> = withContext(coroutineDispatchers.io) {
runCatching {
innerRoom.sendLocation(body, geoUri, genTransactionId())
innerRoom.sendLocation(body, geoUri, null, null, null, genTransactionId())
}
}
}
//TODO handle cancellation, need refactoring of how we are catching errors
private suspend fun sendAttachment(handle: () -> SendAttachmentJoinHandle): Result<Unit> {
return runCatching {
handle().use {
it.join()
}
}
}

Loading…
Cancel
Save