File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed
Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -16,15 +16,7 @@ struct StockProductInfoView: View {
1616
1717 @Binding var stockElement : StockElement ?
1818 @State private var firstOpen : Bool = true
19-
20- var productDetails : StockProductDetails ? {
21- if let productID = stockElement? . productID {
22- Task {
23- try await grocyVM. getStockProductDetails ( productID: productID)
24- }
25- return grocyVM. stockProductDetails [ productID]
26- } else { return nil }
27- }
19+ @State private var productDetails : StockProductDetails ? = nil
2820
2921 var body : some View {
3022 List {
@@ -101,6 +93,16 @@ struct StockProductInfoView: View {
10193 }
10294 }
10395 } )
96+ . task {
97+ do {
98+ if let productID = stockElement? . productID {
99+ try await grocyVM. getStockProductDetails ( productID: productID)
100+ productDetails = grocyVM. stockProductDetails [ productID]
101+ }
102+ } catch {
103+ grocyVM. postLog ( " Get stock detail failed. \( error) " , type: . error)
104+ }
105+ }
104106 }
105107}
106108
You can’t perform that action at this time.
0 commit comments