From 8b346283735a90e5d300eab6b03b3e817fb79bef Mon Sep 17 00:00:00 2001
From: Taras Smakula <tarassmakula@gmail.com>
Date: Tue, 26 Dec 2023 16:17:33 +0200
Subject: [PATCH] Create Invite list item

---
 .../core/mapping/RoomSummaryMapping.kt        | 17 +-------
 .../futo/circles/core/model/InviteListItem.kt | 41 +++++++++++++++++++
 2 files changed, 42 insertions(+), 16 deletions(-)
 create mode 100644 core/src/main/java/org/futo/circles/core/model/InviteListItem.kt

diff --git a/core/src/main/java/org/futo/circles/core/mapping/RoomSummaryMapping.kt b/core/src/main/java/org/futo/circles/core/mapping/RoomSummaryMapping.kt
index d2f894d7d..ca2bb9521 100644
--- a/core/src/main/java/org/futo/circles/core/mapping/RoomSummaryMapping.kt
+++ b/core/src/main/java/org/futo/circles/core/mapping/RoomSummaryMapping.kt
@@ -1,12 +1,8 @@
 package org.futo.circles.core.mapping
 
-import org.futo.circles.core.extensions.notEmptyDisplayName
-import org.futo.circles.core.model.InvitedGalleryListItem
 import org.futo.circles.core.model.JoinedGalleryListItem
 import org.futo.circles.core.model.RoomInfo
 import org.futo.circles.core.model.SelectableRoomListItem
-import org.futo.circles.core.provider.MatrixSessionProvider
-import org.matrix.android.sdk.api.session.getUserOrDefault
 import org.matrix.android.sdk.api.session.room.model.RoomSummary
 
 fun RoomSummary.nameOrId() = displayName.takeIf { it.isNotEmpty() } ?: roomId
@@ -25,15 +21,4 @@ fun RoomSummary.toSelectableRoomListItem(selected: Boolean = false) = Selectable
 fun RoomSummary.toJoinedGalleryListItem() = JoinedGalleryListItem(
     id = roomId,
     info = toRoomInfo()
-)
-
-fun RoomSummary.toInvitedGalleryListItem(shouldBlurIcon: Boolean) = InvitedGalleryListItem(
-    id = roomId,
-    info = toRoomInfo(),
-    inviterName = getInviterName(),
-    shouldBlurIcon = shouldBlurIcon
-)
-
-fun RoomSummary.getInviterName() =
-    MatrixSessionProvider.currentSession?.getUserOrDefault(inviterId ?: "")?.notEmptyDisplayName()
-        ?: ""
\ No newline at end of file
+)
\ No newline at end of file
diff --git a/core/src/main/java/org/futo/circles/core/model/InviteListItem.kt b/core/src/main/java/org/futo/circles/core/model/InviteListItem.kt
new file mode 100644
index 000000000..51039bda2
--- /dev/null
+++ b/core/src/main/java/org/futo/circles/core/model/InviteListItem.kt
@@ -0,0 +1,41 @@
+package org.futo.circles.core.model
+
+import org.futo.circles.core.base.list.IdEntity
+import org.futo.circles.core.extensions.notEmptyDisplayName
+import org.futo.circles.core.mapping.toRoomInfo
+import org.futo.circles.core.provider.MatrixSessionProvider
+import org.matrix.android.sdk.api.session.getUserOrDefault
+import org.matrix.android.sdk.api.session.room.model.RoomSummary
+
+sealed class InviteListItem(
+    override val id: String,
+    open val inviteType: InviteTypeArg
+) : IdEntity<String>
+
+data class RoomInviteListItem(
+    val roomId: String,
+    override val inviteType: InviteTypeArg,
+    val info: RoomInfo,
+    val isEncrypted: Boolean,
+    val inviterName: String,
+    val shouldBlurIcon: Boolean
+) : InviteListItem(roomId, inviteType)
+
+data class FollowRequestListItem(
+    val user: CirclesUserSummary,
+    val reasonMessage: String?
+) : InviteListItem(user.id, InviteTypeArg.People)
+
+fun RoomSummary.toRoomInviteListItem(inviteType: InviteTypeArg, shouldBlurIcon: Boolean) =
+    RoomInviteListItem(
+        roomId = roomId,
+        info = toRoomInfo(),
+        inviterName = getInviterName(),
+        isEncrypted = isEncrypted,
+        shouldBlurIcon = shouldBlurIcon,
+        inviteType = inviteType
+    )
+
+fun RoomSummary.getInviterName() =
+    MatrixSessionProvider.currentSession?.getUserOrDefault(inviterId ?: "")?.notEmptyDisplayName()
+        ?: ""
\ No newline at end of file
-- 
GitLab