Make the RoomListRoomSummaryFactory.createPlaceholder and RoomListRoomSummaryFactory.createFakeList functions static ones
This commit is contained in:
@@ -115,7 +115,7 @@ class RoomListDataSource @Inject constructor(
|
||||
private suspend fun buildAndEmitAllRooms(roomSummaries: List<RoomSummary>) {
|
||||
if (diffCache.isEmpty()) {
|
||||
_allRooms.emit(
|
||||
roomListRoomSummaryFactory.createFakeList()
|
||||
RoomListRoomSummaryFactory.createFakeList()
|
||||
)
|
||||
} else {
|
||||
val roomListRoomSummaries = ArrayList<RoomListRoomSummary>()
|
||||
@@ -135,7 +135,7 @@ class RoomListDataSource @Inject constructor(
|
||||
|
||||
private fun buildAndCacheItem(roomSummaries: List<RoomSummary>, index: Int): RoomListRoomSummary? {
|
||||
val roomListRoomSummary = when (val roomSummary = roomSummaries.getOrNull(index)) {
|
||||
is RoomSummary.Empty -> roomListRoomSummaryFactory.createPlaceholder(roomSummary.identifier)
|
||||
is RoomSummary.Empty -> RoomListRoomSummaryFactory.createPlaceholder(roomSummary.identifier)
|
||||
is RoomSummary.Filled -> roomListRoomSummaryFactory.create(roomSummary)
|
||||
null -> null
|
||||
}
|
||||
|
||||
@@ -32,28 +32,30 @@ class RoomListRoomSummaryFactory @Inject constructor(
|
||||
private val lastMessageTimestampFormatter: LastMessageTimestampFormatter,
|
||||
private val roomLastMessageFormatter: RoomLastMessageFormatter,
|
||||
) {
|
||||
fun createPlaceholder(id: String): RoomListRoomSummary {
|
||||
return RoomListRoomSummary(
|
||||
id = id,
|
||||
roomId = RoomId("!aRoom:domain"),
|
||||
isPlaceholder = true,
|
||||
name = "Short name",
|
||||
timestamp = "hh:mm",
|
||||
lastMessage = "Last message for placeholder",
|
||||
avatarData = AvatarData(id, "S", size = AvatarSize.RoomListItem),
|
||||
numberOfUnreadMessages = 0,
|
||||
numberOfUnreadMentions = 0,
|
||||
numberOfUnreadNotifications = 0,
|
||||
userDefinedNotificationMode = null,
|
||||
hasRoomCall = false,
|
||||
isDm = false,
|
||||
)
|
||||
}
|
||||
companion object {
|
||||
fun createPlaceholder(id: String): RoomListRoomSummary {
|
||||
return RoomListRoomSummary(
|
||||
id = id,
|
||||
roomId = RoomId(id),
|
||||
isPlaceholder = true,
|
||||
name = "Short name",
|
||||
timestamp = "hh:mm",
|
||||
lastMessage = "Last message for placeholder",
|
||||
avatarData = AvatarData(id, "S", size = AvatarSize.RoomListItem),
|
||||
numberOfUnreadMessages = 0,
|
||||
numberOfUnreadMentions = 0,
|
||||
numberOfUnreadNotifications = 0,
|
||||
userDefinedNotificationMode = null,
|
||||
hasRoomCall = false,
|
||||
isDm = false,
|
||||
)
|
||||
}
|
||||
|
||||
fun createFakeList(): ImmutableList<RoomListRoomSummary> {
|
||||
return List(16) {
|
||||
createPlaceholder("!fakeRoom$it:domain")
|
||||
}.toImmutableList()
|
||||
fun createFakeList(): ImmutableList<RoomListRoomSummary> {
|
||||
return List(16) {
|
||||
createPlaceholder("!fakeRoom$it:domain")
|
||||
}.toImmutableList()
|
||||
}
|
||||
}
|
||||
|
||||
fun create(roomSummary: RoomSummary.Filled): RoomListRoomSummary {
|
||||
|
||||
Reference in New Issue
Block a user