forked from GitHub-Mirror/riotX-android
Use CS API to send relation
fix scroll on login view when hs field is hidden
This commit is contained in:
parent
2581bf69e0
commit
d1e9844469
@ -20,5 +20,6 @@ internal object NetworkConstants {
|
|||||||
|
|
||||||
const val URI_API_PREFIX_PATH = "_matrix/client/"
|
const val URI_API_PREFIX_PATH = "_matrix/client/"
|
||||||
const val URI_API_PREFIX_PATH_R0 = "_matrix/client/r0/"
|
const val URI_API_PREFIX_PATH_R0 = "_matrix/client/r0/"
|
||||||
|
const val URI_API_PREFIX_PATH_UNSTABLE = "_matrix/client/unstable/"
|
||||||
|
|
||||||
}
|
}
|
@ -18,7 +18,7 @@ internal class EventRelationsAggregationUpdater(private val credentials: Credent
|
|||||||
when (event.type) {
|
when (event.type) {
|
||||||
EventType.REACTION -> {
|
EventType.REACTION -> {
|
||||||
//we got a reaction!!
|
//we got a reaction!!
|
||||||
Timber.v("###REACTION in room $roomId")
|
Timber.v("###REACTION in room $roomId for event ${event.eventId}")
|
||||||
handleReaction(event, roomId, realm)
|
handleReaction(event, roomId, realm)
|
||||||
}
|
}
|
||||||
EventType.MESSAGE -> {
|
EventType.MESSAGE -> {
|
||||||
|
@ -27,12 +27,7 @@ import im.vector.matrix.android.internal.session.room.send.SendResponse
|
|||||||
import im.vector.matrix.android.internal.session.room.timeline.EventContextResponse
|
import im.vector.matrix.android.internal.session.room.timeline.EventContextResponse
|
||||||
import im.vector.matrix.android.internal.session.room.timeline.PaginationResponse
|
import im.vector.matrix.android.internal.session.room.timeline.PaginationResponse
|
||||||
import retrofit2.Call
|
import retrofit2.Call
|
||||||
import retrofit2.http.Body
|
import retrofit2.http.*
|
||||||
import retrofit2.http.GET
|
|
||||||
import retrofit2.http.POST
|
|
||||||
import retrofit2.http.PUT
|
|
||||||
import retrofit2.http.Path
|
|
||||||
import retrofit2.http.Query
|
|
||||||
|
|
||||||
internal interface RoomAPI {
|
internal interface RoomAPI {
|
||||||
|
|
||||||
@ -170,11 +165,13 @@ internal interface RoomAPI {
|
|||||||
* @param eventType the event type
|
* @param eventType the event type
|
||||||
* @param content the event content
|
* @param content the event content
|
||||||
*/
|
*/
|
||||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/send_relation/{parent_id}/{relation_type}/{event_type}")
|
@PUT(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "rooms/{roomId}/send_relation/{parent_id}/{relation_type}/{event_type}/{txnId}")
|
||||||
fun sendRelation(@Path("roomId") roomId: String,
|
fun sendRelation(@Path("txnId") txId: String,
|
||||||
@Path("parentId") parent_id: String,
|
@Path("roomId") roomId: String,
|
||||||
|
@Path("parent_id") parentId: String,
|
||||||
@Path("relation_type") relationType: String,
|
@Path("relation_type") relationType: String,
|
||||||
@Path("eventType") eventType: String,
|
@Path("event_type") eventType: String,
|
||||||
|
@Query("key") key: String,
|
||||||
@Body content: Content?
|
@Body content: Content?
|
||||||
): Call<SendResponse>
|
): Call<SendResponse>
|
||||||
|
|
||||||
|
@ -18,11 +18,11 @@ package im.vector.matrix.android.internal.session.room.annotation
|
|||||||
import androidx.work.*
|
import androidx.work.*
|
||||||
import im.vector.matrix.android.api.MatrixCallback
|
import im.vector.matrix.android.api.MatrixCallback
|
||||||
import im.vector.matrix.android.api.session.events.model.Event
|
import im.vector.matrix.android.api.session.events.model.Event
|
||||||
|
import im.vector.matrix.android.api.session.events.model.RelationType
|
||||||
import im.vector.matrix.android.api.session.room.model.annotation.ReactionService
|
import im.vector.matrix.android.api.session.room.model.annotation.ReactionService
|
||||||
import im.vector.matrix.android.api.util.Cancelable
|
import im.vector.matrix.android.api.util.Cancelable
|
||||||
import im.vector.matrix.android.internal.session.room.send.LocalEchoEventFactory
|
import im.vector.matrix.android.internal.session.room.send.LocalEchoEventFactory
|
||||||
import im.vector.matrix.android.internal.session.room.send.RedactEventWorker
|
import im.vector.matrix.android.internal.session.room.send.RedactEventWorker
|
||||||
import im.vector.matrix.android.internal.session.room.send.SendEventWorker
|
|
||||||
import im.vector.matrix.android.internal.task.TaskExecutor
|
import im.vector.matrix.android.internal.task.TaskExecutor
|
||||||
import im.vector.matrix.android.internal.task.configureWith
|
import im.vector.matrix.android.internal.task.configureWith
|
||||||
import im.vector.matrix.android.internal.util.CancelableWork
|
import im.vector.matrix.android.internal.util.CancelableWork
|
||||||
@ -46,9 +46,6 @@ internal class DefaultReactionService(private val roomId: String,
|
|||||||
|
|
||||||
override fun sendReaction(reaction: String, targetEventId: String): Cancelable {
|
override fun sendReaction(reaction: String, targetEventId: String): Cancelable {
|
||||||
val event = eventFactory.createReactionEvent(roomId, targetEventId, reaction)
|
val event = eventFactory.createReactionEvent(roomId, targetEventId, reaction)
|
||||||
// .also {
|
|
||||||
// //saveLocalEcho(it)
|
|
||||||
// }
|
|
||||||
val sendRelationWork = createSendRelationWork(event)
|
val sendRelationWork = createSendRelationWork(event)
|
||||||
WorkManager.getInstance()
|
WorkManager.getInstance()
|
||||||
.beginUniqueWork(buildWorkIdentifier(REACTION_WORK), ExistingWorkPolicy.APPEND, sendRelationWork)
|
.beginUniqueWork(buildWorkIdentifier(REACTION_WORK), ExistingWorkPolicy.APPEND, sendRelationWork)
|
||||||
@ -58,12 +55,13 @@ internal class DefaultReactionService(private val roomId: String,
|
|||||||
|
|
||||||
|
|
||||||
private fun createSendRelationWork(event: Event): OneTimeWorkRequest {
|
private fun createSendRelationWork(event: Event): OneTimeWorkRequest {
|
||||||
//TODO use the new API to send relation (for now use regular send)
|
// val sendContentWorkerParams = SendEventWorker.Params(
|
||||||
val sendContentWorkerParams = SendEventWorker.Params(
|
// roomId, event)
|
||||||
roomId, event)
|
val sendContentWorkerParams = SendRelationWorker.Params(
|
||||||
|
roomId, event, RelationType.ANNOTATION)
|
||||||
val sendWorkData = WorkerParamsFactory.toData(sendContentWorkerParams)
|
val sendWorkData = WorkerParamsFactory.toData(sendContentWorkerParams)
|
||||||
|
|
||||||
return OneTimeWorkRequestBuilder<SendEventWorker>()
|
return OneTimeWorkRequestBuilder<SendRelationWorker>()
|
||||||
.setConstraints(WORK_CONSTRAINTS)
|
.setConstraints(WORK_CONSTRAINTS)
|
||||||
.setInputData(sendWorkData)
|
.setInputData(sendWorkData)
|
||||||
.setBackoffCriteria(BackoffPolicy.LINEAR, BACKOFF_DELAY, TimeUnit.MILLISECONDS)
|
.setBackoffCriteria(BackoffPolicy.LINEAR, BACKOFF_DELAY, TimeUnit.MILLISECONDS)
|
||||||
@ -124,17 +122,6 @@ internal class DefaultReactionService(private val roomId: String,
|
|||||||
return "${roomId}_$identifier"
|
return "${roomId}_$identifier"
|
||||||
}
|
}
|
||||||
|
|
||||||
// private fun saveLocalEcho(event: Event) {
|
|
||||||
// monarchy.tryTransactionAsync { realm ->
|
|
||||||
// val roomEntity = RoomEntity.where(realm, roomId = roomId).findFirst()
|
|
||||||
// ?: return@tryTransactionAsync
|
|
||||||
// val liveChunk = ChunkEntity.findLastLiveChunkFromRoom(realm, roomId = roomId)
|
|
||||||
// ?: return@tryTransactionAsync
|
|
||||||
//
|
|
||||||
// roomEntity.addSendingEvent(event, liveChunk.forwardsStateIndex ?: 0)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
//TODO duplicate with send service?
|
//TODO duplicate with send service?
|
||||||
private fun createRedactEventWork(eventId: String, reason: String?): OneTimeWorkRequest {
|
private fun createRedactEventWork(eventId: String, reason: String?): OneTimeWorkRequest {
|
||||||
|
|
||||||
|
@ -24,12 +24,14 @@ import im.vector.matrix.android.api.session.events.model.Event
|
|||||||
import im.vector.matrix.android.api.session.events.model.toModel
|
import im.vector.matrix.android.api.session.events.model.toModel
|
||||||
import im.vector.matrix.android.api.session.room.model.annotation.ReactionContent
|
import im.vector.matrix.android.api.session.room.model.annotation.ReactionContent
|
||||||
import im.vector.matrix.android.api.session.room.model.annotation.ReactionInfo
|
import im.vector.matrix.android.api.session.room.model.annotation.ReactionInfo
|
||||||
|
import im.vector.matrix.android.internal.database.mapper.ContentMapper
|
||||||
import im.vector.matrix.android.internal.di.MatrixKoinComponent
|
import im.vector.matrix.android.internal.di.MatrixKoinComponent
|
||||||
import im.vector.matrix.android.internal.network.executeRequest
|
import im.vector.matrix.android.internal.network.executeRequest
|
||||||
import im.vector.matrix.android.internal.session.room.RoomAPI
|
import im.vector.matrix.android.internal.session.room.RoomAPI
|
||||||
import im.vector.matrix.android.internal.session.room.send.SendResponse
|
import im.vector.matrix.android.internal.session.room.send.SendResponse
|
||||||
import im.vector.matrix.android.internal.util.WorkerParamsFactory
|
import im.vector.matrix.android.internal.util.WorkerParamsFactory
|
||||||
import org.koin.standalone.inject
|
import org.koin.standalone.inject
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
class SendRelationWorker(context: Context, params: WorkerParameters)
|
class SendRelationWorker(context: Context, params: WorkerParameters)
|
||||||
: Worker(context, params), MatrixKoinComponent {
|
: Worker(context, params), MatrixKoinComponent {
|
||||||
@ -57,14 +59,17 @@ class SendRelationWorker(context: Context, params: WorkerParameters)
|
|||||||
val relatedEventId = relationContent.relatesTo?.eventId ?: return Result.failure()
|
val relatedEventId = relationContent.relatesTo?.eventId ?: return Result.failure()
|
||||||
val relationType = (relationContent.relatesTo as? ReactionInfo)?.type ?: params.relationType
|
val relationType = (relationContent.relatesTo as? ReactionInfo)?.type ?: params.relationType
|
||||||
?: return Result.failure()
|
?: return Result.failure()
|
||||||
|
val key = relationContent.relatesTo.key
|
||||||
|
|
||||||
val result = executeRequest<SendResponse> {
|
val result = executeRequest<SendResponse> {
|
||||||
apiCall = roomAPI.sendRelation(
|
apiCall = roomAPI.sendRelation(
|
||||||
|
txId = UUID.randomUUID().toString(),
|
||||||
roomId = params.roomId,
|
roomId = params.roomId,
|
||||||
parent_id = relatedEventId,
|
parentId = relatedEventId,
|
||||||
relationType = relationType,
|
relationType = relationType,
|
||||||
eventType = localEvent.type,
|
eventType = localEvent.type,
|
||||||
content = localEvent.content
|
content = emptyMap(),
|
||||||
|
key = key
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return result.fold({
|
return result.fold({
|
||||||
|
@ -15,7 +15,12 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="24dp">
|
android:paddingStart="24dp"
|
||||||
|
android:paddingLeft="24dp"
|
||||||
|
android:paddingTop="24dp"
|
||||||
|
android:paddingEnd="24dp"
|
||||||
|
android:paddingRight="24dp"
|
||||||
|
android:paddingBottom="80dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/logoImageView"
|
android:id="@+id/logoImageView"
|
||||||
|
Loading…
Reference in New Issue
Block a user