mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor: remove NodeDB users StateFlow
This commit is contained in:
parent
84cfe4f990
commit
eeb3363a88
2 changed files with 4 additions and 11 deletions
|
|
@ -315,11 +315,9 @@ class UIViewModel @Inject constructor(
|
|||
initialValue = emptyList(),
|
||||
)
|
||||
|
||||
fun getMessagesFrom(contactKey: String) = combine(
|
||||
nodeDB.users,
|
||||
packetRepository.getMessagesFrom(contactKey),
|
||||
) { users, packets ->
|
||||
packets.map {
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
fun getMessagesFrom(contactKey: String) = packetRepository.getMessagesFrom(contactKey).mapLatest { list ->
|
||||
list.map {
|
||||
val defaultUser = MeshUser(
|
||||
it.data.from ?: DataPacket.ID_LOCAL,
|
||||
app.getString(R.string.unknown_username),
|
||||
|
|
@ -329,7 +327,7 @@ class UIViewModel @Inject constructor(
|
|||
Message(
|
||||
uuid = it.uuid,
|
||||
receivedTime = it.received_time,
|
||||
user = users[it.data.from] ?: defaultUser,
|
||||
user = nodeDB.nodes.value[it.data.from]?.user ?: defaultUser,
|
||||
text = it.data.text.orEmpty(),
|
||||
time = it.data.time,
|
||||
read = it.read,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue