Skip to content

Commit ecb2c26

Browse files
committed
feat: implement api call
1 parent 7ae5906 commit ecb2c26

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Bitkit/Views/Wallets/Activity/ActivityExplorerView.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ struct ActivityExplorerView: View {
88
@EnvironmentObject var app: AppViewModel
99
@EnvironmentObject var currency: CurrencyViewModel
1010

11+
@State private var txDetails: TxDetails?
12+
@State private var isLoadingTransaction = false
13+
1114
private var onchain: OnchainActivity? {
1215
guard case let .onchain(activity) = item else { return nil }
1316
return activity
@@ -32,6 +35,24 @@ struct ActivityExplorerView: View {
3235
return URL(string: "\(baseUrl)/tx/\(txId)")
3336
}
3437

38+
private func loadTransactionDetails() async {
39+
guard let onchain else { return }
40+
41+
isLoadingTransaction = true
42+
43+
do {
44+
let details = try await AddressChecker.getTransaction(txid: onchain.txId)
45+
await MainActor.run {
46+
txDetails = details
47+
isLoadingTransaction = false
48+
}
49+
} catch {
50+
await MainActor.run {
51+
isLoadingTransaction = false
52+
}
53+
}
54+
}
55+
3556
private var amountPrefix: String {
3657
switch item {
3758
case let .lightning(activity):
@@ -156,6 +177,11 @@ struct ActivityExplorerView: View {
156177
.navigationBarHidden(true)
157178
.padding(.horizontal, 16)
158179
.bottomSafeAreaPadding()
180+
.task {
181+
if onchain != nil {
182+
await loadTransactionDetails()
183+
}
184+
}
159185
}
160186
}
161187

0 commit comments

Comments
 (0)