refactor: make linter happy
This commit is contained in:
@@ -75,10 +75,9 @@ class BalanceViewModel(
|
|||||||
runCatching { repo.getBalance() }
|
runCatching { repo.getBalance() }
|
||||||
.onSuccess { balance ->
|
.onSuccess { balance ->
|
||||||
val sats = balance.sats
|
val sats = balance.sats
|
||||||
val prev = (_balanceState.value as? BalanceState.Success)?.sats
|
when (val prev = (_balanceState.value as? BalanceState.Success)?.sats) {
|
||||||
when {
|
null -> Timber.d("BALANCE [NETWORK ] $sats sats — cold load complete")
|
||||||
prev == null -> Timber.d("BALANCE [NETWORK ] $sats sats — cold load complete")
|
sats -> Timber.d("BALANCE [NETWORK ] $sats sats — matches cache, no change")
|
||||||
prev == sats -> Timber.d("BALANCE [NETWORK ] $sats sats — matches cache, no change")
|
|
||||||
else -> Timber.d("BALANCE [NETWORK ] $sats sats — was $prev sats (diff ${sats - prev})")
|
else -> Timber.d("BALANCE [NETWORK ] $sats sats — was $prev sats (diff ${sats - prev})")
|
||||||
}
|
}
|
||||||
_balanceState.value = BalanceState.Success(
|
_balanceState.value = BalanceState.Success(
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import com.bitcointxoko.gudariwallet.util.satsToFiat
|
|||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
import kotlinx.coroutines.flow.first
|
|
||||||
import kotlinx.coroutines.flow.mapNotNull
|
import kotlinx.coroutines.flow.mapNotNull
|
||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import kotlinx.coroutines.flow.map
|
|||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
|
|
||||||
private const val TAG = "HistoryViewModel"
|
private const val TAG = "HistoryViewModel"
|
||||||
|
|
||||||
@@ -156,7 +157,7 @@ class HistoryViewModel(
|
|||||||
|
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
combine(
|
combine(
|
||||||
_filter.map { it.searchQuery }.debounce(300),
|
_filter.map { it.searchQuery }.debounce(300.milliseconds),
|
||||||
_filter
|
_filter
|
||||||
) { _, f -> f }
|
) { _, f -> f }
|
||||||
.collect { f ->
|
.collect { f ->
|
||||||
@@ -164,10 +165,8 @@ class HistoryViewModel(
|
|||||||
Timber.d("FILTER [IN-MEMORY] filter=default → using cached state")
|
Timber.d("FILTER [IN-MEMORY] filter=default → using cached state")
|
||||||
_roomResults.value = null
|
_roomResults.value = null
|
||||||
} else {
|
} else {
|
||||||
Timber.d("FILTER [ROOM ] q=\"${f.searchQuery}\" " +
|
Timber.d("%snull", "FILTER [ROOM ] q=\"${f.searchQuery}\" " +
|
||||||
"statuses=${f.statuses} dir=${f.direction} types=${f.types} " +
|
"statuses=${f.statuses} dir=${f.direction} types=${f.types} ")
|
||||||
"amt=${f.minAmountSat}–${f.maxAmountSat} " +
|
|
||||||
"date=${f.minCreatedAt}–${f.maxCreatedAt}")
|
|
||||||
_roomResults.value = paymentCache.queryAll(f.searchQuery, f)
|
_roomResults.value = paymentCache.queryAll(f.searchQuery, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import androidx.compose.material.icons.Icons
|
|||||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
import androidx.compose.material.icons.filled.ArrowDownward
|
import androidx.compose.material.icons.filled.ArrowDownward
|
||||||
import androidx.compose.material.icons.filled.ArrowUpward
|
import androidx.compose.material.icons.filled.ArrowUpward
|
||||||
import androidx.compose.material.icons.outlined.ContentCopy
|
|
||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.material3.CircularProgressIndicator
|
import androidx.compose.material3.CircularProgressIndicator
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
|
|||||||
@@ -159,8 +159,7 @@ class PaymentSyncManager(
|
|||||||
val reachedEnd = page.size < WalletConstants.PAYMENTS_PAGE_SIZE
|
val reachedEnd = page.size < WalletConstants.PAYMENTS_PAGE_SIZE
|
||||||
|
|
||||||
if (reachedOverlap || reachedEnd) {
|
if (reachedOverlap || reachedEnd) {
|
||||||
Timber.d("PAYMENTS [SYNC DONE ] $totalNew new payment(s) across $pagesChecked page(s) — " +
|
Timber.d("null%s", if (reachedOverlap) "stopped at known record" else "reached end of history")
|
||||||
if (reachedOverlap) "stopped at known record" else "reached end of history")
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,13 +77,12 @@ class NdefHceService : HostApduService() {
|
|||||||
|
|
||||||
val ins = apdu[1]
|
val ins = apdu[1]
|
||||||
|
|
||||||
return when {
|
return when (ins) {
|
||||||
// ── SELECT (INS = 0xA4) ──────────────────────────────────────────
|
// ── SELECT (INS = 0xA4) ──────────────────────────────────────────
|
||||||
ins == 0xA4.toByte() -> handleSelect(apdu)
|
0xA4.toByte() -> handleSelect(apdu)
|
||||||
|
|
||||||
// ── READ BINARY (INS = 0xB0) ─────────────────────────────────────
|
// ── READ BINARY (INS = 0xB0) ─────────────────────────────────────
|
||||||
ins == 0xB0.toByte() -> handleReadBinary(apdu)
|
0xB0.toByte() -> handleReadBinary(apdu)
|
||||||
|
|
||||||
else -> SW_UNKNOWN
|
else -> SW_UNKNOWN
|
||||||
}.also { Timber.d("APDU OUT: ${it.toHex()}") }
|
}.also { Timber.d("APDU OUT: ${it.toHex()}") }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import androidx.lifecycle.ViewModel
|
|||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.bitcointxoko.gudariwallet.ui.NfcOfferState
|
import com.bitcointxoko.gudariwallet.ui.NfcOfferState
|
||||||
import com.bitcointxoko.gudariwallet.util.SendInputDetector
|
import com.bitcointxoko.gudariwallet.util.SendInputDetector
|
||||||
import com.bitcointxoko.gudariwallet.util.SendInputType
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
@@ -83,7 +82,7 @@ class NfcViewModel : ViewModel() {
|
|||||||
intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)
|
intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rawMessages != null && rawMessages.isNotEmpty()) {
|
if (!rawMessages.isNullOrEmpty()) {
|
||||||
val message = rawMessages[0] as NdefMessage
|
val message = rawMessages[0] as NdefMessage
|
||||||
val uri = extractUri(message)
|
val uri = extractUri(message)
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
@@ -98,7 +97,7 @@ class NfcViewModel : ViewModel() {
|
|||||||
intent.getParcelableExtra(NfcAdapter.EXTRA_TAG, Tag::class.java)
|
intent.getParcelableExtra(NfcAdapter.EXTRA_TAG, Tag::class.java)
|
||||||
} else {
|
} else {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
intent.getParcelableExtra<Tag>(NfcAdapter.EXTRA_TAG)
|
intent.getParcelableExtra(NfcAdapter.EXTRA_TAG)
|
||||||
}
|
}
|
||||||
if (tag != null) {
|
if (tag != null) {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ fun NotificationsPage(
|
|||||||
imageVector = Icons.Default.Notifications,
|
imageVector = Icons.Default.Notifications,
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
modifier = Modifier.size(72.dp),
|
modifier = Modifier.size(72.dp),
|
||||||
// Mirror the BatteryPage tint behaviour
|
// Mirror the BatteryPage tint behavior
|
||||||
tint = if (alreadyGranted)
|
tint = if (alreadyGranted)
|
||||||
MaterialTheme.colorScheme.primary
|
MaterialTheme.colorScheme.primary
|
||||||
else
|
else
|
||||||
@@ -300,7 +300,7 @@ fun NotificationsPage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Page 5: Battery optimisation ──────────────────────────────────────────────
|
// ── Page 5: Battery optimization ──────────────────────────────────────────────
|
||||||
@Composable
|
@Composable
|
||||||
fun BatteryPage(strings: AppStrings) {
|
fun BatteryPage(strings: AppStrings) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|||||||
@@ -13,11 +13,9 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import androidx.work.WorkInfo
|
|
||||||
import com.bitcointxoko.gudariwallet.LocalAppStrings
|
import com.bitcointxoko.gudariwallet.LocalAppStrings
|
||||||
import com.bitcointxoko.gudariwallet.data.HistoricalSyncStore
|
import com.bitcointxoko.gudariwallet.data.HistoricalSyncStore
|
||||||
import com.bitcointxoko.gudariwallet.security.SecretStore
|
import com.bitcointxoko.gudariwallet.security.SecretStore
|
||||||
import com.bitcointxoko.gudariwallet.sync.HistoricalSyncWorker
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user