Skip to content
Merged
13 changes: 13 additions & 0 deletions app/src/main/java/to/bitkit/data/SettingsStore.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package to.bitkit.data

import android.content.Context
import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.datastore.preferences.preferencesDataStore
Expand Down Expand Up @@ -54,9 +55,21 @@ class SettingsStore @Inject constructor(
}
}

val showEmptyState: Flow<Boolean> = store.data
.map {
it[SHOW_EMPTY_STATE] ?: false
}

suspend fun setShowEmptyState(show: Boolean) {
store.edit {
it[SHOW_EMPTY_STATE] = show
}
}

private companion object {
private val PRIMARY_DISPLAY_UNIT_KEY = stringPreferencesKey("primary_display_unit")
private val BTC_DISPLAY_UNIT_KEY = stringPreferencesKey("btc_display_unit")
private val SELECTED_CURRENCY_KEY = stringPreferencesKey("selected_currency")
private val SHOW_EMPTY_STATE = booleanPreferencesKey("show_empty_state")
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/to/bitkit/models/Toast.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package to.bitkit.models
data class Toast(
val type: ToastType,
val title: String,
val description: String,
val description: String? = null,
val autoHide: Boolean,
val visibilityTime: Long,
val visibilityTime: Long = VISIBILITY_TIME_DEFAULT,
) {
enum class ToastType { SUCCESS, INFO, LIGHTNING, WARNING, ERROR }

Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/to/bitkit/services/LightningService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ class LightningService @Inject constructor(
node.start()
}
Log.i(LDK, "Node started")

connectToTrustedPeers()
}

suspend fun stop() {
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/to/bitkit/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class MainActivity : ComponentActivity() {
walletViewModel.setInitNodeLifecycleState()
walletViewModel.createWallet(bip39Passphrase = null)
walletViewModel.setWalletExistsState()
appViewModel.setShowEmptyState(true)
} catch (e: Exception) {
appViewModel.toast(e)
}
Expand All @@ -98,6 +99,7 @@ class MainActivity : ComponentActivity() {
walletViewModel.isRestoringWallet = true
walletViewModel.restoreWallet(mnemonic, passphrase)
walletViewModel.setWalletExistsState()
appViewModel.setShowEmptyState(false)
} catch (e: Exception) {
appViewModel.toast(e)
}
Expand All @@ -114,6 +116,7 @@ class MainActivity : ComponentActivity() {
walletViewModel.setInitNodeLifecycleState()
walletViewModel.createWallet(bip39Passphrase = passphrase)
walletViewModel.setWalletExistsState()
appViewModel.setShowEmptyState(true)
} catch (e: Exception) {
appViewModel.toast(e)
}
Expand Down
Loading