mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Small rework
This commit is contained in:
parent
602ea3327b
commit
128d3845b9
@ -141,7 +141,7 @@ internal class DefaultRelationService @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun fetchEditHistory(eventId: String, callback: MatrixCallback<List<Event>>) {
|
override fun fetchEditHistory(eventId: String, callback: MatrixCallback<List<Event>>) {
|
||||||
val params = FetchEditHistoryTask.Params(roomId, cryptoSessionInfoProvider.isRoomEncrypted(roomId), eventId)
|
val params = FetchEditHistoryTask.Params(roomId, eventId)
|
||||||
fetchEditHistoryTask
|
fetchEditHistoryTask
|
||||||
.configureWith(params) {
|
.configureWith(params) {
|
||||||
this.callback = callback
|
this.callback = callback
|
||||||
|
@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.session.room.relation
|
|||||||
import org.matrix.android.sdk.api.session.events.model.Event
|
import org.matrix.android.sdk.api.session.events.model.Event
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
import org.matrix.android.sdk.api.session.events.model.RelationType
|
import org.matrix.android.sdk.api.session.events.model.RelationType
|
||||||
|
import org.matrix.android.sdk.internal.crypto.CryptoSessionInfoProvider
|
||||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||||
import org.matrix.android.sdk.internal.network.executeRequest
|
import org.matrix.android.sdk.internal.network.executeRequest
|
||||||
import org.matrix.android.sdk.internal.session.room.RoomAPI
|
import org.matrix.android.sdk.internal.session.room.RoomAPI
|
||||||
@ -25,25 +26,27 @@ import org.matrix.android.sdk.internal.task.Task
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal interface FetchEditHistoryTask : Task<FetchEditHistoryTask.Params, List<Event>> {
|
internal interface FetchEditHistoryTask : Task<FetchEditHistoryTask.Params, List<Event>> {
|
||||||
|
|
||||||
data class Params(
|
data class Params(
|
||||||
val roomId: String,
|
val roomId: String,
|
||||||
val isRoomEncrypted: Boolean,
|
|
||||||
val eventId: String
|
val eventId: String
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class DefaultFetchEditHistoryTask @Inject constructor(
|
internal class DefaultFetchEditHistoryTask @Inject constructor(
|
||||||
private val roomAPI: RoomAPI,
|
private val roomAPI: RoomAPI,
|
||||||
private val globalErrorReceiver: GlobalErrorReceiver
|
private val globalErrorReceiver: GlobalErrorReceiver,
|
||||||
|
private val cryptoSessionInfoProvider: CryptoSessionInfoProvider
|
||||||
) : FetchEditHistoryTask {
|
) : FetchEditHistoryTask {
|
||||||
|
|
||||||
override suspend fun execute(params: FetchEditHistoryTask.Params): List<Event> {
|
override suspend fun execute(params: FetchEditHistoryTask.Params): List<Event> {
|
||||||
|
val isRoomEncrypted = cryptoSessionInfoProvider.isRoomEncrypted(params.roomId)
|
||||||
val response = executeRequest<RelationsResponse>(globalErrorReceiver) {
|
val response = executeRequest<RelationsResponse>(globalErrorReceiver) {
|
||||||
apiCall = roomAPI.getRelations(params.roomId,
|
apiCall = roomAPI.getRelations(
|
||||||
params.eventId,
|
roomId = params.roomId,
|
||||||
RelationType.REPLACE,
|
eventId = params.eventId,
|
||||||
if (params.isRoomEncrypted) EventType.ENCRYPTED else EventType.MESSAGE)
|
relationType = RelationType.REPLACE,
|
||||||
|
eventType = if (isRoomEncrypted) EventType.ENCRYPTED else EventType.MESSAGE
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val events = response.chunks.toMutableList()
|
val events = response.chunks.toMutableList()
|
||||||
|
Loading…
Reference in New Issue
Block a user