Skip to content

Commit 3d82c14

Browse files
committed
chore: review
1 parent 9e00713 commit 3d82c14

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

app/src/main/java/to/bitkit/App.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@ internal open class App : Application(), Configuration.Provider {
3636
class CurrentActivity : ActivityLifecycleCallbacks {
3737
var value: Activity? = null
3838
private set
39+
3940
override fun onActivityCreated(activity: Activity, bundle: Bundle?) = Unit
4041
override fun onActivityStarted(activity: Activity) = run { this.value = activity }
4142
override fun onActivityResumed(activity: Activity) = run { this.value = activity }
42-
override fun onActivityPaused(activity: Activity) = run { if (this.value == activity) this.value = null }
43-
override fun onActivityStopped(activity: Activity) = run { if (this.value == activity) this.value = null }
43+
override fun onActivityPaused(activity: Activity) = clearIfCurrent(activity)
44+
override fun onActivityStopped(activity: Activity) = clearIfCurrent(activity)
4445
override fun onActivitySaveInstanceState(activity: Activity, bundle: Bundle) = Unit
45-
override fun onActivityDestroyed(activity: Activity) = run { if (this.value == activity) this.value = null }
46+
override fun onActivityDestroyed(activity: Activity) = clearIfCurrent(activity)
47+
48+
private fun clearIfCurrent(activity: Activity) = run { if (this.value == activity) this.value = null }
4649
}

app/src/main/java/to/bitkit/repositories/LightningRepo.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ class LightningRepo @Inject constructor(
278278

279279
private suspend fun onEvent(event: Event) {
280280
handleLdkEvent(event)
281-
_eventHandlers.forEach { it.invoke(event) }
281+
_eventHandlers.toList().forEach { it.invoke(event) }
282282
_nodeEvents.emit(event)
283283
}
284284

app/src/main/java/to/bitkit/services/LightningService.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ class LightningService @Inject constructor(
101101

102102
trustedPeers?.takeIf { it.isNotEmpty() }?.let {
103103
this.trustedPeers = it
104+
} ?: run {
105+
Logger.info("Using fallback trusted peers from Env (${Env.trustedLnPeers.size})", context = TAG)
104106
}
105107
val trustedPeerNodeIds = this.trustedPeers.map { it.nodeId }
106108

app/src/main/java/to/bitkit/ui/screens/settings/LdkDebugScreen.kt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import to.bitkit.ui.components.TextInput
4141
import to.bitkit.ui.components.settings.SectionFooter
4242
import to.bitkit.ui.components.settings.SectionHeader
4343
import to.bitkit.ui.components.settings.SettingsTextButtonRow
44+
import to.bitkit.ui.scaffold.AppAlertDialog
4445
import to.bitkit.ui.scaffold.AppTopBar
4546
import to.bitkit.ui.scaffold.DrawerNavIcon
4647
import to.bitkit.ui.scaffold.ScreenColumn
@@ -88,6 +89,7 @@ private fun LdkDebugContent(
8889
onRestartNode: () -> Unit,
8990
) {
9091
val context = LocalContext.current
92+
var showDeleteAllConfirmation by remember { mutableStateOf(false) }
9193

9294
ScreenColumn {
9395
AppTopBar(
@@ -202,8 +204,8 @@ private fun LdkDebugContent(
202204
SettingsTextButtonRow(
203205
title = "Delete All",
204206
iconRes = R.drawable.ic_trash,
205-
enabled = !uiState.isLoading,
206-
onClick = onDeleteAllVssKeys,
207+
enabled = !uiState.isLoading && uiState.vssKeys.isNotEmpty(),
208+
onClick = { showDeleteAllConfirmation = true },
207209
)
208210

209211
SectionHeader("NODE")
@@ -217,6 +219,19 @@ private fun LdkDebugContent(
217219
Spacer(modifier = Modifier.height(32.dp))
218220
}
219221
}
222+
223+
if (showDeleteAllConfirmation) {
224+
AppAlertDialog(
225+
title = "Delete All VSS Keys?",
226+
text = "This will permanently delete all ${uiState.vssKeys.size} VSS key(s). This action cannot be undone.",
227+
confirmText = "Delete All",
228+
onConfirm = {
229+
showDeleteAllConfirmation = false
230+
onDeleteAllVssKeys()
231+
},
232+
onDismiss = { showDeleteAllConfirmation = false },
233+
)
234+
}
220235
}
221236

222237
private const val MAX_VSS_KEYS_DISPLAY = 10

0 commit comments

Comments
 (0)