File tree Expand file tree Collapse file tree 2 files changed +70
-8
lines changed
Expand file tree Collapse file tree 2 files changed +70
-8
lines changed Original file line number Diff line number Diff line change @@ -45,12 +45,38 @@ struct NodeStateView: View {
4545 channelsSection
4646 balanceSection
4747 }
48+ . refreshable {
49+ await refreshNodeState ( )
50+ }
4851 }
4952 . navigationBarHidden ( true )
5053 // .padding(.horizontal, 16)
5154 . bottomSafeAreaPadding ( )
5255 }
5356
57+ private func refreshNodeState( ) async {
58+ wallet. syncState ( )
59+
60+ // If node is in an error state or stopped, retry starting it
61+ if case . errorStarting = wallet. nodeLifecycleState {
62+ do {
63+ try await wallet. start ( )
64+ } catch {
65+ await MainActor . run {
66+ app. toast ( error)
67+ }
68+ }
69+ } else if wallet. nodeLifecycleState == . stopped {
70+ do {
71+ try await wallet. start ( )
72+ } catch {
73+ await MainActor . run {
74+ app. toast ( error)
75+ }
76+ }
77+ }
78+ }
79+
5480 var statusSection : some View {
5581 Section {
5682 HStack {
Original file line number Diff line number Diff line change @@ -4,21 +4,25 @@ struct AppStatusView: View {
44 @EnvironmentObject private var navigation : NavigationViewModel
55 @EnvironmentObject private var network : NetworkMonitor
66 @EnvironmentObject private var wallet : WalletViewModel
7+ @EnvironmentObject private var app : AppViewModel
78
89 var body : some View {
910 VStack ( alignment: . leading, spacing: 0 ) {
1011 NavigationBar ( title: t ( " settings__status__title " ) )
1112 . padding ( . bottom, 16 )
1213
13- VStack ( spacing: 16 ) {
14- internetStatusRow
15- bitcoinNodeStatusRow
16- nodeStatusRow
17- channelsStatusRow
18- backupStatusRow
14+ ScrollView {
15+ VStack ( spacing: 16 ) {
16+ internetStatusRow
17+ bitcoinNodeStatusRow
18+ nodeStatusRow
19+ channelsStatusRow
20+ backupStatusRow
21+ }
22+ }
23+ . refreshable {
24+ await refreshAppStatus ( )
1925 }
20-
21- Spacer ( )
2226 }
2327 . navigationBarHidden ( true )
2428 . padding ( . horizontal, 16 )
@@ -28,6 +32,38 @@ struct AppStatusView: View {
2832 }
2933 }
3034
35+ private func refreshAppStatus( ) async {
36+ wallet. syncState ( )
37+
38+ if wallet. nodeLifecycleState == . running {
39+ do {
40+ try await wallet. sync ( )
41+ } catch {
42+ await MainActor . run {
43+ app. toast ( error)
44+ }
45+ }
46+ }
47+
48+ if case . errorStarting = wallet. nodeLifecycleState {
49+ do {
50+ try await wallet. start ( )
51+ } catch {
52+ await MainActor . run {
53+ app. toast ( error)
54+ }
55+ }
56+ } else if wallet. nodeLifecycleState == . stopped {
57+ do {
58+ try await wallet. start ( )
59+ } catch {
60+ await MainActor . run {
61+ app. toast ( error)
62+ }
63+ }
64+ }
65+ }
66+
3167 // MARK: - Status Rows
3268
3369 private var internetStatusRow : some View {
You can’t perform that action at this time.
0 commit comments