forked from GitHub-Mirror/riotX-android
Support AddedByMe in reaction + context menu reflect agree/like state
This commit is contained in:
@ -45,6 +45,7 @@ internal object EventMapper {
|
||||
}
|
||||
|
||||
fun map(eventEntity: EventEntity): Event {
|
||||
//TODO proxy the event to only parse unsigned data when accessed?
|
||||
var ud = if (eventEntity.unsignedData.isNullOrBlank()) null
|
||||
else MoshiProvider.providesMoshi().adapter(UnsignedData::class.java).fromJson(eventEntity.unsignedData)
|
||||
return Event(
|
||||
|
@ -104,7 +104,7 @@ internal class SessionModule(private val sessionParams: SessionParams) {
|
||||
}
|
||||
|
||||
scope(DefaultSession.SCOPE) {
|
||||
EventRelationsAggregationUpdater()
|
||||
EventRelationsAggregationUpdater(get())
|
||||
}
|
||||
|
||||
scope(DefaultSession.SCOPE) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package im.vector.matrix.android.internal.session.room
|
||||
|
||||
import im.vector.matrix.android.api.auth.data.Credentials
|
||||
import im.vector.matrix.android.api.session.events.model.*
|
||||
import im.vector.matrix.android.api.session.room.model.annotation.ReactionContent
|
||||
import im.vector.matrix.android.internal.database.model.EventAnnotationsSummaryEntity
|
||||
@ -10,7 +11,7 @@ import io.realm.Realm
|
||||
import timber.log.Timber
|
||||
|
||||
|
||||
internal class EventRelationsAggregationUpdater {
|
||||
internal class EventRelationsAggregationUpdater(private val credentials: Credentials) {
|
||||
|
||||
fun update(realm: Realm, roomId: String, events: List<Event>?) {
|
||||
events?.forEach { event ->
|
||||
@ -66,12 +67,14 @@ internal class EventRelationsAggregationUpdater {
|
||||
sum.key = reaction
|
||||
sum.firstTimestamp = event.originServerTs ?: 0
|
||||
sum.count = 1
|
||||
sum.addedByMe = sum.addedByMe || (credentials.userId == event.sender)
|
||||
eventSummary.reactionsSummary.add(sum)
|
||||
} else {
|
||||
//is this a known event (is possible? pagination?)
|
||||
if (!sum.sourceEvents.contains(eventId)) {
|
||||
sum.count += 1
|
||||
sum.sourceEvents.add(eventId)
|
||||
sum.addedByMe = sum.addedByMe || (credentials.userId == event.sender)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user