inlining single use extension functions

This commit is contained in:
Adam Brown 2021-10-13 11:32:48 +01:00
parent 86ce6a404e
commit 4748a385ea
1 changed files with 3 additions and 8 deletions

View File

@ -86,9 +86,9 @@ class NotificationFactory @Inject constructor(
invitationNotifications: List<OneShotNotification>,
simpleNotifications: List<OneShotNotification>,
useCompleteNotificationFormat: Boolean): SummaryNotification {
val roomMeta = roomNotifications.mapToMeta()
val invitationMeta = invitationNotifications.mapToMeta()
val simpleMeta = simpleNotifications.mapToMeta()
val roomMeta = roomNotifications.filterIsInstance<RoomNotification.Message>().map { it.meta }
val invitationMeta = invitationNotifications.filterIsInstance<OneShotNotification.Append>().map { it.meta }
val simpleMeta = simpleNotifications.filterIsInstance<OneShotNotification.Append>().map { it.meta }
return when {
roomMeta.isEmpty() && invitationMeta.isEmpty() && simpleMeta.isEmpty() -> SummaryNotification.Removed
else -> SummaryNotification.Update(
@ -102,11 +102,6 @@ class NotificationFactory @Inject constructor(
}
}
private fun List<RoomNotification>.mapToMeta() = filterIsInstance<RoomNotification.Message>().map { it.meta }
@JvmName("mapToMetaOneShotNotification")
private fun List<OneShotNotification>.mapToMeta() = filterIsInstance<OneShotNotification.Append>().map { it.meta }
sealed interface RoomNotification {
data class Removed(val roomId: String) : RoomNotification
data class Message(val notification: Notification, val shortcutInfo: ShortcutInfoCompat?, val meta: Meta) : RoomNotification {