Skip to content

Commit 232c65b

Browse files
committed
Fixed auto redirect to map view issue fixed
- When user have only one workspaces to access and that work space is not configured the long form, we are getting continues loading issue. - Fixed now
1 parent 54577ea commit 232c65b

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

GoInfoGame/GoInfoGame/UI/InitialView/InitialView.swift

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,33 +76,26 @@ struct WorkspacesListView: View {
7676
@State private var showAlert = false
7777

7878
@State private var alertMessage = ""
79+
@State private var autoRedirectToMapViewError: String?
7980

8081
var body: some View {
8182

82-
if viewModel.workspaces?.count == 1 {
83-
if let selectedWorkspace = viewModel.workspaces?.first {
84-
VStack {
85-
if !shouldNavigateToMapView {
86-
ActivityView(activityText: "Fetching workspace data...")
87-
Spacer()
88-
}
89-
}
90-
.onAppear {
91-
viewModel.fetchLongQuestsFor(workspaceId: "\(selectedWorkspace.id)") { success, errorMessage in
92-
if success {
93-
self.selectedWorkspace = selectedWorkspace
94-
let workspaceId = "\(selectedWorkspace.id)"
95-
_ = KeychainManager.save(key: "workspaceID", data: workspaceId)
96-
DispatchQueue.main.async {
97-
shouldNavigateToMapView = true
98-
}
99-
} else {
100-
DispatchQueue.main.async {
101-
alertMessage = errorMessage ?? "Something went wrong. Please pick another workspace."
102-
showAlert = true
103-
shouldNavigateToMapView = false
104-
}
83+
if viewModel.workspaces?.count == 1,
84+
let selectedWorkspace = viewModel.workspaces?.first,
85+
autoRedirectToMapViewError == nil {
86+
VStack {
87+
}
88+
.onAppear {
89+
viewModel.fetchLongQuestsFor(workspaceId: "\(selectedWorkspace.id)") { success, errorMessage in
90+
if success {
91+
self.selectedWorkspace = selectedWorkspace
92+
let workspaceId = "\(selectedWorkspace.id)"
93+
_ = KeychainManager.save(key: "workspaceID", data: workspaceId)
94+
DispatchQueue.main.async {
95+
shouldNavigateToMapView = true
10596
}
97+
} else {
98+
autoRedirectToMapViewError = errorMessage ?? "Something went wrong. Please pick another workspace."
10699
}
107100
}
108101
}

0 commit comments

Comments
 (0)