Handle invite to the current user rendering

This commit is contained in:
Benoit Marty 2019-09-06 15:48:42 +02:00
parent 2a92a3dc80
commit cf0b331c3b

View File

@ -24,12 +24,14 @@ import im.vector.matrix.android.api.session.room.model.*
import im.vector.matrix.android.api.session.room.model.call.CallInviteContent import im.vector.matrix.android.api.session.room.model.call.CallInviteContent
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
import im.vector.riotx.R import im.vector.riotx.R
import im.vector.riotx.core.di.ActiveSessionHolder
import im.vector.riotx.core.resources.StringProvider import im.vector.riotx.core.resources.StringProvider
import im.vector.riotx.features.home.room.detail.timeline.helper.senderName import im.vector.riotx.features.home.room.detail.timeline.helper.senderName
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject


class NoticeEventFormatter @Inject constructor(private val stringProvider: StringProvider) { class NoticeEventFormatter @Inject constructor(private val sessionHolder: ActiveSessionHolder,
private val stringProvider: StringProvider) {


fun format(timelineEvent: TimelineEvent): CharSequence? { fun format(timelineEvent: TimelineEvent): CharSequence? {
return when (val type = timelineEvent.root.getClearType()) { return when (val type = timelineEvent.root.getClearType()) {
@ -167,8 +169,7 @@ class NoticeEventFormatter @Inject constructor(private val stringProvider: Strin
val targetDisplayName = eventContent?.displayName ?: prevEventContent?.displayName ?: "" val targetDisplayName = eventContent?.displayName ?: prevEventContent?.displayName ?: ""
return when { return when {
Membership.INVITE == eventContent?.membership -> { Membership.INVITE == eventContent?.membership -> {
// TODO get userId val selfUserId = sessionHolder.getSafeActiveSession()?.myUserId
val selfUserId = ""
when { when {
eventContent.thirdPartyInvite != null -> { eventContent.thirdPartyInvite != null -> {
val userWhoHasAccepted = eventContent.thirdPartyInvite?.signed?.mxid ?: event.stateKey val userWhoHasAccepted = eventContent.thirdPartyInvite?.signed?.mxid ?: event.stateKey