File tree Expand file tree Collapse file tree 3 files changed +13
-9
lines changed
app/src/main/java/to/bitkit Expand file tree Collapse file tree 3 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -105,3 +105,11 @@ data class SettingsData(
105105 val electrumServer : ElectrumServer = Env .defaultElectrumServer,
106106 val rgsServerUrl : String? = Env .ldkRgsServerUrl,
107107)
108+
109+ fun SettingsData.resetPin () = this .copy(
110+ isPinEnabled = false ,
111+ isPinOnLaunchEnabled = true ,
112+ isPinOnIdleEnabled = false ,
113+ isPinForPaymentsEnabled = false ,
114+ isBiometricEnabled = false ,
115+ )
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import to.bitkit.data.WidgetsData
2121import to.bitkit.data.WidgetsStore
2222import to.bitkit.data.backup.VssBackupsClient
2323import to.bitkit.data.backup.VssObjectInfo
24+ import to.bitkit.data.resetPin
2425import to.bitkit.di.BgDispatcher
2526import to.bitkit.di.json
2627import to.bitkit.ext.formatPlural
@@ -243,7 +244,7 @@ class BackupsRepo @Inject constructor(
243244
244245 private suspend fun getBackupDataBytes (category : BackupCategory ): ByteArray = when (category) {
245246 BackupCategory .SETTINGS -> {
246- val data = settingsStore.data.first()
247+ val data = settingsStore.data.first().resetPin()
247248 json.encodeToString(data).toByteArray()
248249 }
249250
@@ -295,7 +296,7 @@ class BackupsRepo @Inject constructor(
295296
296297 return @withContext try {
297298 performRestore(BackupCategory .SETTINGS ) { dataBytes ->
298- val parsed = json.decodeFromString<SettingsData >(String (dataBytes))
299+ val parsed = json.decodeFromString<SettingsData >(String (dataBytes)).resetPin()
299300 settingsStore.update { parsed }
300301 }
301302 performRestore(BackupCategory .WIDGETS ) { dataBytes ->
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ import org.lightningdevkit.ldknode.Txid
3535import to.bitkit.R
3636import to.bitkit.data.SettingsStore
3737import to.bitkit.data.keychain.Keychain
38+ import to.bitkit.data.resetPin
3839import to.bitkit.di.BgDispatcher
3940import to.bitkit.env.Env
4041import to.bitkit.ext.WatchResult
@@ -1132,13 +1133,7 @@ class AppViewModel @Inject constructor(
11321133 fun removePin () {
11331134 viewModelScope.launch(bgDispatcher) {
11341135 settingsStore.update {
1135- it.copy(
1136- isPinEnabled = false ,
1137- isPinOnLaunchEnabled = true ,
1138- isPinOnIdleEnabled = false ,
1139- isPinForPaymentsEnabled = false ,
1140- isBiometricEnabled = false ,
1141- )
1136+ it.resetPin()
11421137 }
11431138 keychain.delete(Keychain .Key .PIN .name)
11441139 keychain.upsertString(Keychain .Key .PIN_ATTEMPTS_REMAINING .name, Env .PIN_ATTEMPTS .toString())
You can’t perform that action at this time.
0 commit comments