Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions api/src/main/java/com/getcode/network/HistoryController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ class HistoryController @Inject constructor(
private fun owner(): KeyPair? = SessionManager.getKeyPair()

suspend fun fetchChats() {
pagerMap.clear()
chatFlows.clear()

val containers = fetchChatsWithoutMessages()
Timber.d("chats fetched = ${containers.count()}")
_chats.value = containers
Expand All @@ -93,8 +96,6 @@ class HistoryController @Inject constructor(
}

_chats.value = updatedWithMessages.sortedByDescending { it.lastMessageMillis }

pagerMap.clear()
}

suspend fun advanceReadPointer(chatId: ID) {
Expand Down
55 changes: 25 additions & 30 deletions app/src/main/java/com/getcode/view/main/home/HomeViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,8 @@ class HomeViewModel @Inject constructor(
)
}
.subscribe({
viewModelScope.launch {
cancelSend(PresentationStyle.Pop)
vibrator.vibrate()
historyController.fetchChats()
}
cancelSend(PresentationStyle.Pop)
vibrator.vibrate()
}, {
ErrorUtils.handleError(it)
cancelSend(style = PresentationStyle.Slide)
Expand Down Expand Up @@ -426,43 +423,41 @@ class HomeViewModel @Inject constructor(
sendTransactionDisposable?.dispose()
BottomBarManager.clearByType(BottomBarManager.BottomBarMessageType.REMOTE_SEND)

val shown = showToastIfNeeded(style)

uiFlow.update {
it.copy(
presentationStyle = style,
billState = it.billState.copy(
bill = null,
viewModelScope.launch {
historyController.fetchChats()

val shown = showToastIfNeeded(style)

uiFlow.update {
it.copy(
presentationStyle = style,
billState = it.billState.copy(
bill = null,
)
)
)
}
}

viewModelScope.launch {
if (shown) {
delay(300)
}
withContext(Dispatchers.Main) {
uiFlow.update {
it.copy(
billState = it.billState.copy(
valuation = null,
hideBillButtons = false
)

uiFlow.update {
it.copy(
billState = it.billState.copy(
valuation = null,
hideBillButtons = false
)
}
)
}
}

viewModelScope.launch {
if (shown) {
delay(5.seconds.inWholeMilliseconds)
}
withContext(Dispatchers.Main) {
uiFlow.update {
it.copy(
billState = it.billState.copy(showToast = false)
)
}
uiFlow.update {
it.copy(
billState = it.billState.copy(showToast = false)
)
}
}
}
Expand Down