feat: Update call started timeline item + declined support
This commit is contained in:
parent
d215354e64
commit
f0dc4eeace
9 changed files with 138 additions and 42 deletions
|
|
@ -55,6 +55,7 @@ class DefaultRoomLatestEventFormatter(
|
|||
private val profileChangeContentFormatter: ProfileChangeContentFormatter,
|
||||
private val stateContentFormatter: StateContentFormatter,
|
||||
private val permalinkParser: PermalinkParser,
|
||||
private val rtcNotificationContentFormatter: RtcNotificationContentFormatter,
|
||||
) : RoomLatestEventFormatter {
|
||||
override fun format(
|
||||
latestEvent: LatestEventValue.Local,
|
||||
|
|
@ -121,7 +122,7 @@ class DefaultRoomLatestEventFormatter(
|
|||
message.prefixIfNeeded(senderDisambiguatedDisplayName, isDmRoom, isOutgoing)
|
||||
}
|
||||
is LegacyCallInviteContent -> sp.getString(CommonStrings.common_unsupported_call)
|
||||
is CallNotifyContent -> sp.getString(CommonStrings.common_call_started)
|
||||
is CallNotifyContent -> rtcNotificationContentFormatter.format(content, isDmRoom)
|
||||
}?.take(DEFAULT_SAFE_LENGTH)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2026 Element Creations Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.eventformatter.impl
|
||||
|
||||
import dev.zacsweers.metro.Inject
|
||||
import io.element.android.libraries.matrix.api.MatrixClient
|
||||
import io.element.android.libraries.matrix.api.timeline.item.event.CallNotifyContent
|
||||
import io.element.android.libraries.ui.strings.CommonStrings
|
||||
import io.element.android.services.toolbox.api.strings.StringProvider
|
||||
|
||||
@Inject
|
||||
class RtcNotificationContentFormatter(
|
||||
private val matrixClient: MatrixClient,
|
||||
private val sp: StringProvider,
|
||||
) {
|
||||
fun format(
|
||||
content: CallNotifyContent,
|
||||
isDm: Boolean,
|
||||
): CharSequence {
|
||||
return if (isDm) {
|
||||
val isDeclined = content.declinedBy.isNotEmpty()
|
||||
val isDeclinedByMe = content.declinedBy.any { matrixClient.isMe(it) }
|
||||
if (isDeclinedByMe) {
|
||||
sp.getString(CommonStrings.common_call_you_declined)
|
||||
} else if (isDeclined) {
|
||||
sp.getString(CommonStrings.common_call_declined)
|
||||
} else {
|
||||
sp.getString(CommonStrings.common_call_started)
|
||||
}
|
||||
} else {
|
||||
sp.getString(CommonStrings.common_call_started)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -119,7 +119,8 @@ data class LiveLocationContent(
|
|||
data object LegacyCallInviteContent : EventContent
|
||||
|
||||
data class CallNotifyContent(
|
||||
val callIntent: CallIntent
|
||||
val callIntent: CallIntent,
|
||||
val declinedBy: List<UserId>
|
||||
) : EventContent
|
||||
|
||||
data object UnknownContent : EventContent
|
||||
|
|
|
|||
|
|
@ -153,7 +153,8 @@ class TimelineEventContentMapper(
|
|||
CallIntent.AUDIO
|
||||
} else {
|
||||
CallIntent.VIDEO
|
||||
}
|
||||
},
|
||||
declinedBy = it.declinedBy.map(::UserId)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue