Merge pull request #2015 from element-hq/feature/bma/asyncMedia
ReadReceipt
This commit is contained in:
@@ -48,6 +48,7 @@ import io.element.android.libraries.matrix.api.encryption.EncryptionService
|
||||
import io.element.android.libraries.matrix.api.room.MatrixRoom
|
||||
import io.element.android.libraries.matrix.api.room.MessageEventType
|
||||
import io.element.android.libraries.matrix.api.room.roomMembers
|
||||
import io.element.android.libraries.matrix.api.timeline.ReceiptType
|
||||
import io.element.android.libraries.matrix.api.timeline.item.event.TimelineItemEventOrigin
|
||||
import io.element.android.libraries.matrix.api.verification.SessionVerificationService
|
||||
import io.element.android.libraries.matrix.api.verification.SessionVerifiedStatus
|
||||
@@ -236,7 +237,7 @@ class TimelinePresenter @AssistedInject constructor(
|
||||
if (eventId != null && firstVisibleIndex <= lastReadReceiptIndex.value && eventId != lastReadReceiptId.value) {
|
||||
lastReadReceiptIndex.value = firstVisibleIndex
|
||||
lastReadReceiptId.value = eventId
|
||||
timeline.sendReadReceipt(eventId)
|
||||
timeline.sendReadReceipt(eventId = eventId, receiptType = ReceiptType.READ)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ jsoup = "org.jsoup:jsoup:1.17.1"
|
||||
appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" }
|
||||
molecule-runtime = "app.cash.molecule:molecule-runtime:1.3.1"
|
||||
timber = "com.jakewharton.timber:timber:5.0.1"
|
||||
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.1.76"
|
||||
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.1.77"
|
||||
matrix_richtexteditor = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" }
|
||||
matrix_richtexteditor_compose = { module = "io.element.android:wysiwyg-compose", version.ref = "wysiwyg" }
|
||||
sqldelight-driver-android = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" }
|
||||
|
||||
@@ -20,7 +20,7 @@ import io.element.android.libraries.matrix.api.core.EventId
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
||||
interface MatrixTimeline: AutoCloseable {
|
||||
interface MatrixTimeline : AutoCloseable {
|
||||
|
||||
data class PaginationState(
|
||||
val isBackPaginating: Boolean,
|
||||
@@ -36,5 +36,5 @@ interface MatrixTimeline: AutoCloseable {
|
||||
suspend fun paginateBackwards(requestSize: Int, untilNumberOfItems: Int): Result<Unit>
|
||||
suspend fun fetchDetailsForEvent(eventId: EventId): Result<Unit>
|
||||
|
||||
suspend fun sendReadReceipt(eventId: EventId): Result<Unit>
|
||||
suspend fun sendReadReceipt(eventId: EventId, receiptType: ReceiptType): Result<Unit>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2023 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.matrix.api.timeline
|
||||
|
||||
enum class ReceiptType {
|
||||
READ,
|
||||
READ_PRIVATE,
|
||||
FULLY_READ;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2023 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.matrix.impl.timeline
|
||||
|
||||
import io.element.android.libraries.matrix.api.timeline.ReceiptType
|
||||
import org.matrix.rustcomponents.sdk.ReceiptType as RustReceiptType
|
||||
|
||||
internal fun ReceiptType.toRustReceiptType(): RustReceiptType = when (this) {
|
||||
ReceiptType.READ -> RustReceiptType.READ
|
||||
ReceiptType.READ_PRIVATE -> RustReceiptType.READ_PRIVATE
|
||||
ReceiptType.FULLY_READ -> RustReceiptType.FULLY_READ
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import io.element.android.libraries.matrix.api.core.EventId
|
||||
import io.element.android.libraries.matrix.api.room.MatrixRoom
|
||||
import io.element.android.libraries.matrix.api.timeline.MatrixTimeline
|
||||
import io.element.android.libraries.matrix.api.timeline.MatrixTimelineItem
|
||||
import io.element.android.libraries.matrix.api.timeline.ReceiptType
|
||||
import io.element.android.libraries.matrix.api.timeline.TimelineException
|
||||
import io.element.android.libraries.matrix.api.timeline.item.virtual.VirtualTimelineItem
|
||||
import io.element.android.libraries.matrix.impl.timeline.item.event.EventMessageMapper
|
||||
@@ -217,9 +218,15 @@ class RustMatrixTimeline(
|
||||
return isInit.get() && paginationState.value.canBackPaginate
|
||||
}
|
||||
|
||||
override suspend fun sendReadReceipt(eventId: EventId) = withContext(dispatcher) {
|
||||
override suspend fun sendReadReceipt(
|
||||
eventId: EventId,
|
||||
receiptType: ReceiptType,
|
||||
) = withContext(dispatcher) {
|
||||
runCatching {
|
||||
innerTimeline.sendReadReceipt(eventId = eventId.value)
|
||||
innerTimeline.sendReadReceipt(
|
||||
receiptType = receiptType.toRustReceiptType(),
|
||||
eventId = eventId.value,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package io.element.android.libraries.matrix.test.timeline
|
||||
import io.element.android.libraries.matrix.api.core.EventId
|
||||
import io.element.android.libraries.matrix.api.timeline.MatrixTimeline
|
||||
import io.element.android.libraries.matrix.api.timeline.MatrixTimelineItem
|
||||
import io.element.android.libraries.matrix.api.timeline.ReceiptType
|
||||
import io.element.android.tests.testutils.simulateLongTask
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
import kotlinx.coroutines.delay
|
||||
@@ -74,7 +75,10 @@ class FakeMatrixTimeline(
|
||||
Result.success(Unit)
|
||||
}
|
||||
|
||||
override suspend fun sendReadReceipt(eventId: EventId): Result<Unit> = simulateLongTask {
|
||||
override suspend fun sendReadReceipt(
|
||||
eventId: EventId,
|
||||
receiptType: ReceiptType,
|
||||
): Result<Unit> = simulateLongTask {
|
||||
sendReadReceiptCount++
|
||||
sendReadReceiptLatch?.complete(Unit)
|
||||
Result.success(Unit)
|
||||
|
||||
@@ -8,6 +8,7 @@ read -p "Do you want to build the Rust SDK from local source (yes/no) default to
|
||||
buildLocal=${buildLocal:-yes}
|
||||
|
||||
date=$(gdate +%Y%m%d%H%M%S)
|
||||
elementPwd=`pwd`
|
||||
|
||||
# Ask for the Rust SDK local source path
|
||||
# if folder rustSdk/ exists, use it as default
|
||||
@@ -28,7 +29,7 @@ else
|
||||
cd matrix-rust-sdk-$date
|
||||
git checkout ${rustSdkBranch}
|
||||
rustSdkPath=$(pwd)
|
||||
cd ../element-x-android
|
||||
cd ${elementPwd}
|
||||
fi
|
||||
|
||||
|
||||
@@ -46,6 +47,8 @@ fi
|
||||
read -p "Do you want to build the app after (yes/no) default to yes? " buildApp
|
||||
buildApp=${buildApp:-yes}
|
||||
|
||||
cd ${elementPwd}
|
||||
|
||||
# If folder ../matrix-rust-components-kotlin does not exist, clone the repo
|
||||
if [ ! -d "../matrix-rust-components-kotlin" ]; then
|
||||
printf "\nFolder ../matrix-rust-components-kotlin does not exist. Cloning the repository into ../matrix-rust-components-kotlin.\n\n"
|
||||
@@ -59,9 +62,9 @@ git checkout main
|
||||
git pull
|
||||
|
||||
printf "\nBuilding the SDK for aarch64-linux-android...\n\n"
|
||||
./scripts/build.sh -p ${rustSdkPath} -m sdk -t aarch64-linux-android -o ../element-x-android/libraries/rustsdk
|
||||
./scripts/build.sh -p ${rustSdkPath} -m sdk -t aarch64-linux-android -o ${elementPwd}/libraries/rustsdk
|
||||
|
||||
cd ../element-x-android
|
||||
cd ${elementPwd}
|
||||
mv ./libraries/rustsdk/sdk-android-debug.aar ./libraries/rustsdk/matrix-rust-sdk.aar
|
||||
mkdir -p ./libraries/rustsdk/sdks
|
||||
cp ./libraries/rustsdk/matrix-rust-sdk.aar ./libraries/rustsdk/sdks/matrix-rust-sdk-${date}.aar
|
||||
|
||||
Reference in New Issue
Block a user