File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed
app/src/main/java/to/bitkit/ui/screens/wallets Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -153,32 +153,30 @@ class HomeViewModel @Inject constructor(
153153 delay(CHECK_DELAY_MILLISECONDS )
154154
155155 val settings = settingsStore.data.first()
156+ val currentTime = Clock .System .now().toEpochMilliseconds()
156157
157158 val totalOnChainSats = walletRepo.balanceState.value.totalSats
158159 val balanceUsd = satsToUsd(totalOnChainSats) ? : return @launch
159160 val thresholdReached = balanceUsd > BigDecimal (BALANCE_THRESHOLD_USD )
160- val isTimeOutOver = if (settings.lastTimeAskedBalanceWarningMillis == 0L ) {
161- true
162- } else {
163- settings.lastTimeAskedBalanceWarningMillis - ASK_INTERVAL_MILLIS > ASK_INTERVAL_MILLIS
164- }
161+
162+ val isTimeOutOver = settings.lastTimeAskedBalanceWarningMillis == 0L ||
163+ (currentTime - settings.lastTimeAskedBalanceWarningMillis > ASK_INTERVAL_MILLIS )
164+
165165 val belowMaxWarnings = settings.balanceWarningTimes < MAX_WARNINGS
166166
167- if (thresholdReached && isTimeOutOver && belowMaxWarnings && ! _uiState .value.highBalanceSheetVisible ) {
167+ if (thresholdReached && isTimeOutOver && belowMaxWarnings) {
168168 settingsStore.update {
169169 it.copy(
170170 balanceWarningTimes = it.balanceWarningTimes + 1 ,
171- lastTimeAskedBalanceWarningMillis = Clock . System .now().toEpochMilliseconds()
171+ lastTimeAskedBalanceWarningMillis = currentTime
172172 )
173173 }
174174 _uiState .update { it.copy(highBalanceSheetVisible = true ) }
175175 }
176176
177177 if (! thresholdReached) {
178178 settingsStore.update {
179- it.copy(
180- balanceWarningTimes = 0 ,
181- )
179+ it.copy(balanceWarningTimes = 0 )
182180 }
183181 }
184182 }
You can’t perform that action at this time.
0 commit comments