Skip to content

Commit

Permalink
Show failed to load objects in dev mode
Browse files Browse the repository at this point in the history
It helps for debugging purposes and shows which objects failed to load.
  • Loading branch information
supergeorg committed May 26, 2023
1 parent 36c80b8 commit d10efce
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Shared/Views/Additional/ServerProblemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ struct ServerProblemView: View {

@StateObject var grocyVM: GrocyViewModel = .shared

@AppStorage("devMode") private var devMode: Bool = false

private enum ServerErrorState: Identifiable {
case connection, api, other, none

Expand Down Expand Up @@ -82,6 +84,18 @@ struct ServerProblemView: View {
})
.buttonStyle(FilledButtonStyle())
.controlSize(.large)
if devMode {
List() {
ForEach(grocyVM.failedToLoadObjects.sorted(by: { $0.rawValue < $1.rawValue }), id: \.self) { object in
Text(object.rawValue)
}
}
List() {
ForEach(grocyVM.failedToLoadAdditionalObjects.sorted(by: { $0.rawValue < $1.rawValue }), id: \.self) { additionalObject in
Text(additionalObject.rawValue)
}
}
}
}
.padding()
.background(.regularMaterial)
Expand Down

0 comments on commit d10efce

Please sign in to comment.