@@ -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
6666struct 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
0 commit comments