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,10 +32,11 @@ class RoomListRoomSummaryFactory @Inject constructor(
|
||||||
private val lastMessageTimestampFormatter: LastMessageTimestampFormatter,
|
private val lastMessageTimestampFormatter: LastMessageTimestampFormatter,
|
||||||
private val roomLastMessageFormatter: RoomLastMessageFormatter,
|
private val roomLastMessageFormatter: RoomLastMessageFormatter,
|
||||||
) {
|
) {
|
||||||
|
companion object {
|
||||||
fun createPlaceholder(id: String): RoomListRoomSummary {
|
fun createPlaceholder(id: String): RoomListRoomSummary {
|
||||||
return RoomListRoomSummary(
|
return RoomListRoomSummary(
|
||||||
id = id,
|
id = id,
|
||||||
roomId = RoomId("!aRoom:domain"),
|
roomId = RoomId(id),
|
||||||
isPlaceholder = true,
|
isPlaceholder = true,
|
||||||
name = "Short name",
|
name = "Short name",
|
||||||
timestamp = "hh:mm",
|
timestamp = "hh:mm",
|
||||||
|
|
@ -55,6 +56,7 @@ class RoomListRoomSummaryFactory @Inject constructor(
|
||||||
createPlaceholder("!fakeRoom$it:domain")
|
createPlaceholder("!fakeRoom$it:domain")
|
||||||
}.toImmutableList()
|
}.toImmutableList()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun create(roomSummary: RoomSummary.Filled): RoomListRoomSummary {
|
fun create(roomSummary: RoomSummary.Filled): RoomListRoomSummary {
|
||||||
val roomIdentifier = roomSummary.identifier()
|
val roomIdentifier = roomSummary.identifier()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue