Skip to content

Commit 4e9933d

Browse files
committed
Updated message to display right message before loading the workspaces
1 parent 7eee96f commit 4e9933d

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

GoInfoGame/GoInfoGame/UI/InitialView/InitialView.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct InitialView: View {
4343

4444
Spacer()
4545

46-
WorkspacesListView(workspaces: viewModel.workspaces, viewModel: viewModel, shouldNavigateToMapView: $shouldNavigateToMapView, selectedWorkspace: $selectedWorkspace, isLoading: $viewModel.isLoading)
46+
WorkspacesListView(viewModel: viewModel, shouldNavigateToMapView: $shouldNavigateToMapView, selectedWorkspace: $selectedWorkspace, isLoading: $viewModel.isLoading)
4747
}
4848
.padding()
4949

@@ -64,7 +64,6 @@ struct InitialView: View {
6464

6565
// WorkspacesListView - View for displaying a list of workspaces
6666
struct WorkspacesListView: View {
67-
let workspaces: [Workspace]
6867
var viewModel: InitialViewModel
6968
@Binding var shouldNavigateToMapView: Bool
7069
@Binding var selectedWorkspace: Workspace?
@@ -77,8 +76,8 @@ struct WorkspacesListView: View {
7776

7877
var body: some View {
7978

80-
if viewModel.workspaces.count == 1 {
81-
if let selectedWorkspace = viewModel.workspaces.first {
79+
if viewModel.workspaces?.count == 1 {
80+
if let selectedWorkspace = viewModel.workspaces?.first {
8281
VStack {
8382
if !shouldNavigateToMapView {
8483
ActivityView(activityText: "Fetching workspace data...")
@@ -104,7 +103,15 @@ struct WorkspacesListView: View {
104103
}
105104
}
106105
}
107-
} else if viewModel.workspaces.count == 0 {
106+
} else if viewModel.workspaces == nil {
107+
VStack {
108+
Text("Loading workspaces available for you... Please make sure you have location service enabled.")
109+
.font(.custom("Lato-Bold", size: 20))
110+
.foregroundColor((Color(red: 135/255, green: 62/255, blue: 242/255)))
111+
.multilineTextAlignment(.center)
112+
Spacer()
113+
}
114+
} else if viewModel.workspaces?.count == 0 {
108115
VStack {
109116
Text("No workspaces available for you to work on.")
110117
.font(.custom("Lato-Bold", size: 20))
@@ -121,7 +128,7 @@ struct WorkspacesListView: View {
121128

122129
ScrollView {
123130
VStack(spacing: 20) {
124-
ForEach(workspaces.filter({$0.type == "osw" && $0.externalAppAccess == 1}), id: \.id) { workspace in
131+
ForEach(viewModel.workspaces?.filter({$0.type == "osw" && $0.externalAppAccess == 1}) ?? [], id: \.id) { workspace in
125132
Button {
126133
viewModel.checkAndDeleteWorkspaceDB(workspaceId: "\(workspace.id)")
127134
viewModel.fetchLongQuestsFor(workspaceId: "\(workspace.id)", completion: { success, errorMessage in

GoInfoGame/GoInfoGame/UI/InitialView/InitialViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import LocalAuthentication
1414
@MainActor
1515
class InitialViewModel: ObservableObject {
1616
let locationManagerDelegate = LocationManagerDelegate()
17-
@Published var workspaces: [Workspace] = []
17+
@Published var workspaces: [Workspace]? = nil
1818
@Published var longQuests: [LongFormElement] = []
1919
@Published var isLoading: Bool = false
2020

0 commit comments

Comments
 (0)