Merge pull request #626 from vector-im/feature/myUserIdInject
Inject userId where possible
This commit is contained in:
commit
723a007c39
@ -50,21 +50,19 @@ interface RelationService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a reaction (emoji) to the targetedEvent.
|
* Sends a reaction (emoji) to the targetedEvent.
|
||||||
* @param reaction the reaction (preferably emoji)
|
|
||||||
* @param targetEventId the id of the event being reacted
|
* @param targetEventId the id of the event being reacted
|
||||||
|
* @param reaction the reaction (preferably emoji)
|
||||||
*/
|
*/
|
||||||
fun sendReaction(reaction: String,
|
fun sendReaction(targetEventId: String,
|
||||||
targetEventId: String): Cancelable
|
reaction: String): Cancelable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undo a reaction (emoji) to the targetedEvent.
|
* Undo a reaction (emoji) to the targetedEvent.
|
||||||
* @param reaction the reaction (preferably emoji)
|
|
||||||
* @param targetEventId the id of the event being reacted
|
* @param targetEventId the id of the event being reacted
|
||||||
* @param myUserId used to know if a reaction event was made by the user
|
* @param reaction the reaction (preferably emoji)
|
||||||
*/
|
*/
|
||||||
fun undoReaction(reaction: String,
|
fun undoReaction(targetEventId: String,
|
||||||
targetEventId: String,
|
reaction: String): Cancelable
|
||||||
myUserId: String) // : Cancelable
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit a text message body. Limited to "m.text" contentType
|
* Edit a text message body. Limited to "m.text" contentType
|
||||||
@ -92,7 +90,7 @@ interface RelationService {
|
|||||||
compatibilityBodyText: String = "* $newBodyText"): Cancelable
|
compatibilityBodyText: String = "* $newBodyText"): Cancelable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get's the edit history of the given event
|
* Get the edit history of the given event
|
||||||
*/
|
*/
|
||||||
fun fetchEditHistory(eventId: String, callback: MatrixCallback<List<Event>>)
|
fun fetchEditHistory(eventId: String, callback: MatrixCallback<List<Event>>)
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ import im.vector.matrix.android.internal.crypto.model.OlmInboundGroupSessionWrap
|
|||||||
import im.vector.matrix.android.internal.crypto.store.IMXCryptoStore
|
import im.vector.matrix.android.internal.crypto.store.IMXCryptoStore
|
||||||
import im.vector.matrix.android.internal.crypto.store.db.model.KeysBackupDataEntity
|
import im.vector.matrix.android.internal.crypto.store.db.model.KeysBackupDataEntity
|
||||||
import im.vector.matrix.android.internal.di.MoshiProvider
|
import im.vector.matrix.android.internal.di.MoshiProvider
|
||||||
|
import im.vector.matrix.android.internal.di.UserId
|
||||||
import im.vector.matrix.android.internal.extensions.foldToCallback
|
import im.vector.matrix.android.internal.extensions.foldToCallback
|
||||||
import im.vector.matrix.android.internal.session.SessionScope
|
import im.vector.matrix.android.internal.session.SessionScope
|
||||||
import im.vector.matrix.android.internal.task.Task
|
import im.vector.matrix.android.internal.task.Task
|
||||||
@ -77,6 +78,7 @@ import kotlin.random.Random
|
|||||||
|
|
||||||
@SessionScope
|
@SessionScope
|
||||||
internal class KeysBackup @Inject constructor(
|
internal class KeysBackup @Inject constructor(
|
||||||
|
@UserId private val userId: String,
|
||||||
private val credentials: Credentials,
|
private val credentials: Credentials,
|
||||||
private val cryptoStore: IMXCryptoStore,
|
private val cryptoStore: IMXCryptoStore,
|
||||||
private val olmDevice: MXOlmDevice,
|
private val olmDevice: MXOlmDevice,
|
||||||
@ -375,8 +377,6 @@ internal class KeysBackup @Inject constructor(
|
|||||||
*/
|
*/
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
private fun getKeysBackupTrustBg(keysBackupVersion: KeysVersionResult): KeysBackupVersionTrust {
|
private fun getKeysBackupTrustBg(keysBackupVersion: KeysVersionResult): KeysBackupVersionTrust {
|
||||||
val myUserId = credentials.userId
|
|
||||||
|
|
||||||
val keysBackupVersionTrust = KeysBackupVersionTrust()
|
val keysBackupVersionTrust = KeysBackupVersionTrust()
|
||||||
val authData = keysBackupVersion.getAuthDataAsMegolmBackupAuthData()
|
val authData = keysBackupVersion.getAuthDataAsMegolmBackupAuthData()
|
||||||
|
|
||||||
@ -388,7 +388,7 @@ internal class KeysBackup @Inject constructor(
|
|||||||
return keysBackupVersionTrust
|
return keysBackupVersionTrust
|
||||||
}
|
}
|
||||||
|
|
||||||
val mySigs = authData.signatures?.get(myUserId)
|
val mySigs = authData.signatures?.get(userId)
|
||||||
if (mySigs.isNullOrEmpty()) {
|
if (mySigs.isNullOrEmpty()) {
|
||||||
Timber.v("getKeysBackupTrust: Ignoring key backup because it lacks any signatures from this user")
|
Timber.v("getKeysBackupTrust: Ignoring key backup because it lacks any signatures from this user")
|
||||||
return keysBackupVersionTrust
|
return keysBackupVersionTrust
|
||||||
@ -403,7 +403,7 @@ internal class KeysBackup @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (deviceId != null) {
|
if (deviceId != null) {
|
||||||
val device = cryptoStore.getUserDevice(deviceId, myUserId)
|
val device = cryptoStore.getUserDevice(deviceId, userId)
|
||||||
var isSignatureValid = false
|
var isSignatureValid = false
|
||||||
|
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
@ -450,10 +450,8 @@ internal class KeysBackup @Inject constructor(
|
|||||||
} else {
|
} else {
|
||||||
GlobalScope.launch(coroutineDispatchers.main) {
|
GlobalScope.launch(coroutineDispatchers.main) {
|
||||||
val updateKeysBackupVersionBody = withContext(coroutineDispatchers.crypto) {
|
val updateKeysBackupVersionBody = withContext(coroutineDispatchers.crypto) {
|
||||||
val myUserId = credentials.userId
|
|
||||||
|
|
||||||
// Get current signatures, or create an empty set
|
// Get current signatures, or create an empty set
|
||||||
val myUserSignatures = authData.signatures?.get(myUserId)?.toMutableMap()
|
val myUserSignatures = authData.signatures?.get(userId)?.toMutableMap()
|
||||||
?: HashMap()
|
?: HashMap()
|
||||||
|
|
||||||
if (trust) {
|
if (trust) {
|
||||||
@ -462,7 +460,7 @@ internal class KeysBackup @Inject constructor(
|
|||||||
|
|
||||||
val deviceSignatures = objectSigner.signObject(canonicalJson)
|
val deviceSignatures = objectSigner.signObject(canonicalJson)
|
||||||
|
|
||||||
deviceSignatures[myUserId]?.forEach { entry ->
|
deviceSignatures[userId]?.forEach { entry ->
|
||||||
myUserSignatures[entry.key] = entry.value
|
myUserSignatures[entry.key] = entry.value
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -478,7 +476,7 @@ internal class KeysBackup @Inject constructor(
|
|||||||
val newMegolmBackupAuthData = authData.copy()
|
val newMegolmBackupAuthData = authData.copy()
|
||||||
|
|
||||||
val newSignatures = newMegolmBackupAuthData.signatures!!.toMutableMap()
|
val newSignatures = newMegolmBackupAuthData.signatures!!.toMutableMap()
|
||||||
newSignatures[myUserId] = myUserSignatures
|
newSignatures[userId] = myUserSignatures
|
||||||
|
|
||||||
newMegolmBackupAuthData.signatures = newSignatures
|
newMegolmBackupAuthData.signatures = newSignatures
|
||||||
|
|
||||||
@ -1411,5 +1409,5 @@ internal class KeysBackup @Inject constructor(
|
|||||||
* DEBUG INFO
|
* DEBUG INFO
|
||||||
* ========================================================================================== */
|
* ========================================================================================== */
|
||||||
|
|
||||||
override fun toString() = "KeysBackup for ${credentials.userId}"
|
override fun toString() = "KeysBackup for $userId"
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ internal class DefaultRelationService @AssistedInject constructor(@Assisted priv
|
|||||||
fun create(roomId: String): RelationService
|
fun create(roomId: String): RelationService
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun sendReaction(reaction: String, targetEventId: String): Cancelable {
|
override fun sendReaction(targetEventId: String, reaction: String): Cancelable {
|
||||||
val event = eventFactory.createReactionEvent(roomId, targetEventId, reaction)
|
val event = eventFactory.createReactionEvent(roomId, targetEventId, reaction)
|
||||||
.also {
|
.also {
|
||||||
saveLocalEcho(it)
|
saveLocalEcho(it)
|
||||||
@ -75,13 +75,13 @@ internal class DefaultRelationService @AssistedInject constructor(@Assisted priv
|
|||||||
return CancelableWork(context, sendRelationWork.id)
|
return CancelableWork(context, sendRelationWork.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun undoReaction(reaction: String, targetEventId: String, myUserId: String)/*: Cancelable*/ {
|
override fun undoReaction(targetEventId: String, reaction: String): Cancelable {
|
||||||
val params = FindReactionEventForUndoTask.Params(
|
val params = FindReactionEventForUndoTask.Params(
|
||||||
roomId,
|
roomId,
|
||||||
targetEventId,
|
targetEventId,
|
||||||
reaction,
|
reaction
|
||||||
myUserId
|
|
||||||
)
|
)
|
||||||
|
// TODO We should avoid using MatrixCallback internally
|
||||||
val callback = object : MatrixCallback<FindReactionEventForUndoTask.Result> {
|
val callback = object : MatrixCallback<FindReactionEventForUndoTask.Result> {
|
||||||
override fun onSuccess(data: FindReactionEventForUndoTask.Result) {
|
override fun onSuccess(data: FindReactionEventForUndoTask.Result) {
|
||||||
if (data.redactEventId == null) {
|
if (data.redactEventId == null) {
|
||||||
@ -89,7 +89,6 @@ internal class DefaultRelationService @AssistedInject constructor(@Assisted priv
|
|||||||
// TODO?
|
// TODO?
|
||||||
}
|
}
|
||||||
data.redactEventId?.let { toRedact ->
|
data.redactEventId?.let { toRedact ->
|
||||||
|
|
||||||
val redactEvent = eventFactory.createRedactEvent(roomId, toRedact, null).also {
|
val redactEvent = eventFactory.createRedactEvent(roomId, toRedact, null).also {
|
||||||
saveLocalEcho(it)
|
saveLocalEcho(it)
|
||||||
}
|
}
|
||||||
@ -99,7 +98,7 @@ internal class DefaultRelationService @AssistedInject constructor(@Assisted priv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
findReactionEventForUndoTask
|
return findReactionEventForUndoTask
|
||||||
.configureWith(params) {
|
.configureWith(params) {
|
||||||
this.retryCount = Int.MAX_VALUE
|
this.retryCount = Int.MAX_VALUE
|
||||||
this.callback = callback
|
this.callback = callback
|
||||||
|
@ -20,6 +20,7 @@ import im.vector.matrix.android.internal.database.model.EventAnnotationsSummaryE
|
|||||||
import im.vector.matrix.android.internal.database.model.EventEntity
|
import im.vector.matrix.android.internal.database.model.EventEntity
|
||||||
import im.vector.matrix.android.internal.database.model.ReactionAggregatedSummaryEntityFields
|
import im.vector.matrix.android.internal.database.model.ReactionAggregatedSummaryEntityFields
|
||||||
import im.vector.matrix.android.internal.database.query.where
|
import im.vector.matrix.android.internal.database.query.where
|
||||||
|
import im.vector.matrix.android.internal.di.UserId
|
||||||
import im.vector.matrix.android.internal.task.Task
|
import im.vector.matrix.android.internal.task.Task
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -29,8 +30,7 @@ internal interface FindReactionEventForUndoTask : Task<FindReactionEventForUndoT
|
|||||||
data class Params(
|
data class Params(
|
||||||
val roomId: String,
|
val roomId: String,
|
||||||
val eventId: String,
|
val eventId: String,
|
||||||
val reaction: String,
|
val reaction: String
|
||||||
val myUserId: String
|
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Result(
|
data class Result(
|
||||||
@ -38,16 +38,17 @@ internal interface FindReactionEventForUndoTask : Task<FindReactionEventForUndoT
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class DefaultFindReactionEventForUndoTask @Inject constructor(private val monarchy: Monarchy) : FindReactionEventForUndoTask {
|
internal class DefaultFindReactionEventForUndoTask @Inject constructor(private val monarchy: Monarchy,
|
||||||
|
@UserId private val userId: String) : FindReactionEventForUndoTask {
|
||||||
|
|
||||||
override suspend fun execute(params: FindReactionEventForUndoTask.Params): FindReactionEventForUndoTask.Result {
|
override suspend fun execute(params: FindReactionEventForUndoTask.Params): FindReactionEventForUndoTask.Result {
|
||||||
val eventId = Realm.getInstance(monarchy.realmConfiguration).use { realm ->
|
val eventId = Realm.getInstance(monarchy.realmConfiguration).use { realm ->
|
||||||
getReactionToRedact(realm, params.reaction, params.eventId, params.myUserId)?.eventId
|
getReactionToRedact(realm, params.reaction, params.eventId)?.eventId
|
||||||
}
|
}
|
||||||
return FindReactionEventForUndoTask.Result(eventId)
|
return FindReactionEventForUndoTask.Result(eventId)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getReactionToRedact(realm: Realm, reaction: String, eventId: String, userId: String): EventEntity? {
|
private fun getReactionToRedact(realm: Realm, reaction: String, eventId: String): EventEntity? {
|
||||||
val summary = EventAnnotationsSummaryEntity.where(realm, eventId).findFirst()
|
val summary = EventAnnotationsSummaryEntity.where(realm, eventId).findFirst()
|
||||||
if (summary != null) {
|
if (summary != null) {
|
||||||
summary.reactionsSummary.where()
|
summary.reactionsSummary.where()
|
||||||
|
@ -20,6 +20,7 @@ import im.vector.matrix.android.internal.database.model.EventAnnotationsSummaryE
|
|||||||
import im.vector.matrix.android.internal.database.model.EventEntity
|
import im.vector.matrix.android.internal.database.model.EventEntity
|
||||||
import im.vector.matrix.android.internal.database.model.ReactionAggregatedSummaryEntityFields
|
import im.vector.matrix.android.internal.database.model.ReactionAggregatedSummaryEntityFields
|
||||||
import im.vector.matrix.android.internal.database.query.where
|
import im.vector.matrix.android.internal.database.query.where
|
||||||
|
import im.vector.matrix.android.internal.di.UserId
|
||||||
import im.vector.matrix.android.internal.task.Task
|
import im.vector.matrix.android.internal.task.Task
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -30,8 +31,7 @@ internal interface UpdateQuickReactionTask : Task<UpdateQuickReactionTask.Params
|
|||||||
val roomId: String,
|
val roomId: String,
|
||||||
val eventId: String,
|
val eventId: String,
|
||||||
val reaction: String,
|
val reaction: String,
|
||||||
val oppositeReaction: String,
|
val oppositeReaction: String
|
||||||
val myUserId: String
|
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Result(
|
data class Result(
|
||||||
@ -40,17 +40,18 @@ internal interface UpdateQuickReactionTask : Task<UpdateQuickReactionTask.Params
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class DefaultUpdateQuickReactionTask @Inject constructor(private val monarchy: Monarchy) : UpdateQuickReactionTask {
|
internal class DefaultUpdateQuickReactionTask @Inject constructor(private val monarchy: Monarchy,
|
||||||
|
@UserId private val userId: String) : UpdateQuickReactionTask {
|
||||||
|
|
||||||
override suspend fun execute(params: UpdateQuickReactionTask.Params): UpdateQuickReactionTask.Result {
|
override suspend fun execute(params: UpdateQuickReactionTask.Params): UpdateQuickReactionTask.Result {
|
||||||
var res: Pair<String?, List<String>?>? = null
|
var res: Pair<String?, List<String>?>? = null
|
||||||
monarchy.doWithRealm { realm ->
|
monarchy.doWithRealm { realm ->
|
||||||
res = updateQuickReaction(realm, params.reaction, params.oppositeReaction, params.eventId, params.myUserId)
|
res = updateQuickReaction(realm, params.reaction, params.oppositeReaction, params.eventId)
|
||||||
}
|
}
|
||||||
return UpdateQuickReactionTask.Result(res?.first, res?.second ?: emptyList())
|
return UpdateQuickReactionTask.Result(res?.first, res?.second ?: emptyList())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateQuickReaction(realm: Realm, reaction: String, oppositeReaction: String, eventId: String, myUserId: String): Pair<String?, List<String>?> {
|
private fun updateQuickReaction(realm: Realm, reaction: String, oppositeReaction: String, eventId: String): Pair<String?, List<String>?> {
|
||||||
// the emoji reaction has been selected, we need to check if we have reacted it or not
|
// the emoji reaction has been selected, we need to check if we have reacted it or not
|
||||||
val existingSummary = EventAnnotationsSummaryEntity.where(realm, eventId).findFirst()
|
val existingSummary = EventAnnotationsSummaryEntity.where(realm, eventId).findFirst()
|
||||||
?: return Pair(reaction, null)
|
?: return Pair(reaction, null)
|
||||||
@ -68,7 +69,7 @@ internal class DefaultUpdateQuickReactionTask @Inject constructor(private val mo
|
|||||||
val toRedact = aggregationForOppositeReaction?.sourceEvents?.mapNotNull {
|
val toRedact = aggregationForOppositeReaction?.sourceEvents?.mapNotNull {
|
||||||
// find source event
|
// find source event
|
||||||
val entity = EventEntity.where(realm, it).findFirst()
|
val entity = EventEntity.where(realm, it).findFirst()
|
||||||
if (entity?.sender == myUserId) entity.eventId else null
|
if (entity?.sender == userId) entity.eventId else null
|
||||||
}
|
}
|
||||||
return Pair(reaction, toRedact)
|
return Pair(reaction, toRedact)
|
||||||
} else {
|
} else {
|
||||||
@ -77,7 +78,7 @@ internal class DefaultUpdateQuickReactionTask @Inject constructor(private val mo
|
|||||||
val toRedact = aggregationForReaction.sourceEvents.mapNotNull {
|
val toRedact = aggregationForReaction.sourceEvents.mapNotNull {
|
||||||
// find source event
|
// find source event
|
||||||
val entity = EventEntity.where(realm, it).findFirst()
|
val entity = EventEntity.where(realm, it).findFirst()
|
||||||
if (entity?.sender == myUserId) entity.eventId else null
|
if (entity?.sender == userId) entity.eventId else null
|
||||||
}
|
}
|
||||||
return Pair(null, toRedact)
|
return Pair(null, toRedact)
|
||||||
}
|
}
|
||||||
|
@ -342,11 +342,11 @@ class PushrulesConditionTest {
|
|||||||
TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun sendReaction(reaction: String, targetEventId: String): Cancelable {
|
override fun sendReaction(targetEventId: String, reaction: String): Cancelable {
|
||||||
TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun undoReaction(reaction: String, targetEventId: String, myUserId: String) {
|
override fun undoReaction(targetEventId: String, reaction: String): Cancelable {
|
||||||
TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,9 +30,9 @@ sealed class RoomDetailActions {
|
|||||||
data class TimelineEventTurnsVisible(val event: TimelineEvent) : RoomDetailActions()
|
data class TimelineEventTurnsVisible(val event: TimelineEvent) : RoomDetailActions()
|
||||||
data class TimelineEventTurnsInvisible(val event: TimelineEvent) : RoomDetailActions()
|
data class TimelineEventTurnsInvisible(val event: TimelineEvent) : RoomDetailActions()
|
||||||
data class LoadMoreTimelineEvents(val direction: Timeline.Direction) : RoomDetailActions()
|
data class LoadMoreTimelineEvents(val direction: Timeline.Direction) : RoomDetailActions()
|
||||||
data class SendReaction(val reaction: String, val targetEventId: String) : RoomDetailActions()
|
data class SendReaction(val targetEventId: String, val reaction: String) : RoomDetailActions()
|
||||||
|
data class UndoReaction(val targetEventId: String, val reaction: String, val reason: String? = "") : RoomDetailActions()
|
||||||
data class RedactAction(val targetEventId: String, val reason: String? = "") : RoomDetailActions()
|
data class RedactAction(val targetEventId: String, val reason: String? = "") : RoomDetailActions()
|
||||||
data class UndoReaction(val targetEventId: String, val key: String, val reason: String? = "") : RoomDetailActions()
|
|
||||||
data class UpdateQuickReactAction(val targetEventId: String, val selectedReaction: String, val add: Boolean) : RoomDetailActions()
|
data class UpdateQuickReactAction(val targetEventId: String, val selectedReaction: String, val add: Boolean) : RoomDetailActions()
|
||||||
data class NavigateToEvent(val eventId: String, val highlight: Boolean) : RoomDetailActions()
|
data class NavigateToEvent(val eventId: String, val highlight: Boolean) : RoomDetailActions()
|
||||||
data class SetReadMarkerAction(val eventId: String) : RoomDetailActions()
|
data class SetReadMarkerAction(val eventId: String) : RoomDetailActions()
|
||||||
|
@ -420,7 +420,7 @@ class RoomDetailFragment :
|
|||||||
val eventId = data.getStringExtra(EmojiReactionPickerActivity.EXTRA_EVENT_ID) ?: return
|
val eventId = data.getStringExtra(EmojiReactionPickerActivity.EXTRA_EVENT_ID) ?: return
|
||||||
val reaction = data.getStringExtra(EmojiReactionPickerActivity.EXTRA_REACTION_RESULT) ?: return
|
val reaction = data.getStringExtra(EmojiReactionPickerActivity.EXTRA_REACTION_RESULT) ?: return
|
||||||
// TODO check if already reacted with that?
|
// TODO check if already reacted with that?
|
||||||
roomDetailViewModel.process(RoomDetailActions.SendReaction(reaction, eventId))
|
roomDetailViewModel.process(RoomDetailActions.SendReaction(eventId, reaction))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -909,7 +909,7 @@ class RoomDetailFragment :
|
|||||||
override fun onClickOnReactionPill(informationData: MessageInformationData, reaction: String, on: Boolean) {
|
override fun onClickOnReactionPill(informationData: MessageInformationData, reaction: String, on: Boolean) {
|
||||||
if (on) {
|
if (on) {
|
||||||
// we should test the current real state of reaction on this event
|
// we should test the current real state of reaction on this event
|
||||||
roomDetailViewModel.process(RoomDetailActions.SendReaction(reaction, informationData.eventId))
|
roomDetailViewModel.process(RoomDetailActions.SendReaction(informationData.eventId, reaction))
|
||||||
} else {
|
} else {
|
||||||
// I need to redact a reaction
|
// I need to redact a reaction
|
||||||
roomDetailViewModel.process(RoomDetailActions.UndoReaction(informationData.eventId, reaction))
|
roomDetailViewModel.process(RoomDetailActions.UndoReaction(informationData.eventId, reaction))
|
||||||
|
@ -445,7 +445,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun handleSendReaction(action: RoomDetailActions.SendReaction) {
|
private fun handleSendReaction(action: RoomDetailActions.SendReaction) {
|
||||||
room.sendReaction(action.reaction, action.targetEventId)
|
room.sendReaction(action.targetEventId, action.reaction)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleRedactEvent(action: RoomDetailActions.RedactAction) {
|
private fun handleRedactEvent(action: RoomDetailActions.RedactAction) {
|
||||||
@ -454,14 +454,14 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun handleUndoReact(action: RoomDetailActions.UndoReaction) {
|
private fun handleUndoReact(action: RoomDetailActions.UndoReaction) {
|
||||||
room.undoReaction(action.key, action.targetEventId, session.myUserId)
|
room.undoReaction(action.targetEventId, action.reaction)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleUpdateQuickReaction(action: RoomDetailActions.UpdateQuickReactAction) {
|
private fun handleUpdateQuickReaction(action: RoomDetailActions.UpdateQuickReactAction) {
|
||||||
if (action.add) {
|
if (action.add) {
|
||||||
room.sendReaction(action.selectedReaction, action.targetEventId)
|
room.sendReaction(action.targetEventId, action.selectedReaction)
|
||||||
} else {
|
} else {
|
||||||
room.undoReaction(action.selectedReaction, action.targetEventId, session.myUserId)
|
room.undoReaction(action.targetEventId, action.selectedReaction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user