mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Small rework
This commit is contained in:
parent
602ea3327b
commit
128d3845b9
2 changed files with 11 additions and 8 deletions
|
@ -141,7 +141,7 @@ internal class DefaultRelationService @AssistedInject constructor(
|
|||
}
|
||||
|
||||
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
|
||||
.configureWith(params) {
|
||||
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.EventType
|
||||
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.executeRequest
|
||||
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
|
||||
|
||||
internal interface FetchEditHistoryTask : Task<FetchEditHistoryTask.Params, List<Event>> {
|
||||
|
||||
data class Params(
|
||||
val roomId: String,
|
||||
val isRoomEncrypted: Boolean,
|
||||
val eventId: String
|
||||
)
|
||||
}
|
||||
|
||||
internal class DefaultFetchEditHistoryTask @Inject constructor(
|
||||
private val roomAPI: RoomAPI,
|
||||
private val globalErrorReceiver: GlobalErrorReceiver
|
||||
private val globalErrorReceiver: GlobalErrorReceiver,
|
||||
private val cryptoSessionInfoProvider: CryptoSessionInfoProvider
|
||||
) : FetchEditHistoryTask {
|
||||
|
||||
override suspend fun execute(params: FetchEditHistoryTask.Params): List<Event> {
|
||||
val isRoomEncrypted = cryptoSessionInfoProvider.isRoomEncrypted(params.roomId)
|
||||
val response = executeRequest<RelationsResponse>(globalErrorReceiver) {
|
||||
apiCall = roomAPI.getRelations(params.roomId,
|
||||
params.eventId,
|
||||
RelationType.REPLACE,
|
||||
if (params.isRoomEncrypted) EventType.ENCRYPTED else EventType.MESSAGE)
|
||||
apiCall = roomAPI.getRelations(
|
||||
roomId = params.roomId,
|
||||
eventId = params.eventId,
|
||||
relationType = RelationType.REPLACE,
|
||||
eventType = if (isRoomEncrypted) EventType.ENCRYPTED else EventType.MESSAGE
|
||||
)
|
||||
}
|
||||
|
||||
val events = response.chunks.toMutableList()
|
||||
|
|
Loading…
Reference in a new issue