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