Skip to content

Commit f80a2c7

Browse files
authored
Merge pull request #177 from code-payments/fix/fetch-chats-more
chore: fetch chats when needed
2 parents 88a9b5f + 5a746ad commit f80a2c7

4 files changed

Lines changed: 11 additions & 11 deletions

File tree

api/src/main/java/com/getcode/network/HistoryController.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ class HistoryController @Inject constructor(
9494

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

97-
pagerMap.entries.onEach { (id, pagingSource) ->
98-
pagingSource.invalidate()
99-
}
97+
pagerMap.clear()
10098
}
10199

102100
suspend fun advanceReadPointer(chatId: ID) {

api/src/main/java/com/getcode/network/client/Client_Transaction.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ suspend fun Client.receiveRemoteSuspend(giftCard: GiftCardAccount): KinAmount =
185185
)
186186

187187
balanceController.fetchBalanceSuspend()
188-
// TODO: fetch chats here somehow?
189188

190189
return@withContext kinAmount
191190
}

api/src/main/java/com/getcode/network/repository/PaymentRepository.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ import javax.inject.Inject
2525
import kotlin.coroutines.resume
2626
import kotlin.coroutines.resumeWithException
2727

28-
data class Request(
29-
val amount: KinAmount,
30-
val payload: CodePayload,
31-
)
3228

3329
class PaymentRepository @Inject constructor(
3430
@ApplicationContext private val context: Context,

app/src/main/java/com/getcode/view/main/home/HomeViewModel.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,11 @@ class HomeViewModel @Inject constructor(
343343
)
344344
}
345345
.subscribe({
346-
cancelSend(PresentationStyle.Pop)
347-
vibrator.vibrate()
348-
viewModelScope.launch { historyController.fetchChats() }
346+
viewModelScope.launch {
347+
cancelSend(PresentationStyle.Pop)
348+
vibrator.vibrate()
349+
historyController.fetchChats()
350+
}
349351
}, {
350352
ErrorUtils.handleError(it)
351353
cancelSend(style = PresentationStyle.Slide)
@@ -671,6 +673,8 @@ class HomeViewModel @Inject constructor(
671673
paymentConfirmation.payload.rendezvous
672674
)
673675
}.onSuccess {
676+
historyController.fetchChats()
677+
674678
showToast(paymentConfirmation.localAmount, false)
675679

676680
withContext(Dispatchers.Main) {
@@ -1128,6 +1132,9 @@ class HomeViewModel @Inject constructor(
11281132
)
11291133
analytics.cashLinkGrab(amount.kin, amount.rate.currency)
11301134
analytics.onBillReceived()
1135+
1136+
historyController.fetchChats()
1137+
11311138
viewModelScope.launch(Dispatchers.Main) {
11321139
BottomBarManager.clear()
11331140
showBill(

0 commit comments

Comments
 (0)