Skip to content

Commit

Permalink
#345 testing code to fix issue in field books. Without luck.
Browse files Browse the repository at this point in the history
  • Loading branch information
ghuotvez committed Jun 21, 2024
1 parent 1277a0e commit 4d91395
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions GSCFieldApp/ViewModels/FieldBooksPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class FieldBooksPageViewModel : ViewModelBase
#region INITIALIZATION

//UI
public ObservableCollection<FieldBooks> _projectCollection = new ObservableCollection<FieldBooks>();
private ObservableCollection<FieldBooks> _projectCollection = new ObservableCollection<FieldBooks>();
public int _selectedProjectIndex = -1;
private bool _noFieldBookWatermark = false;

Expand Down Expand Up @@ -71,6 +71,7 @@ public class FieldBooksPageViewModel : ViewModelBase
public ObservableCollection<FieldBooks> ProjectCollection
{
get { return _projectCollection; }
set { _projectCollection = value; }
}

public bool ProgressRingActive
Expand All @@ -90,11 +91,8 @@ public bool ProgressRingVisibility

public FieldBooksPageViewModel()
{
_projectCollection = new ObservableCollection<FieldBooks>();
RaisePropertyChanged("ProjectCollection");

//Fill list view of projects
FillProjectCollectionAsync();
_ = FillProjectCollectionAsync();

//Detect new field book save
GSCFieldApp.Views.FieldBookDialog.newFieldBookSaved -= FieldBookDialog_newFieldBookSaved;
Expand All @@ -119,9 +117,9 @@ private void FieldBookDialog_newFieldBookSaved(object sender, EventArgs e)
/// <summary>
/// Will fill the project collection with information related to it
/// </summary>
private async void FillProjectCollectionAsync()
private async Task<ObservableCollection<FieldBooks>> FillProjectCollectionAsync()
{
_projectCollection.Clear();
_projectCollection = new ObservableCollection<FieldBooks>();
RaisePropertyChanged("ProjectCollection");
List<string> invalidFieldBookToDelete = new List<string>();

Expand Down Expand Up @@ -189,16 +187,15 @@ private async void FillProjectCollectionAsync()
{
currentDB.StationNumber = 0.ToString();
}


#endregion
_projectCollection.Add(currentDB);
if (!_projectCollection.Contains(currentDB))
{
_projectCollection.Add(currentDB);
}

currentConnection.Close();
GC.Collect();
GC.WaitForPendingFinalizers();

System.Runtime.InteropServices.Marshal.ReleaseComObject(sfi);

break; //Forget about other files
}
Expand All @@ -207,7 +204,7 @@ private async void FillProjectCollectionAsync()
}

//Refresh UI
RaisePropertyChanged("ProjectCollection");
//RaisePropertyChanged("ProjectCollection");

//Select the current active project, so it's highlighted in the list view
ResourceLoader loadLocal = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
Expand All @@ -231,6 +228,7 @@ private async void FillProjectCollectionAsync()
fieldBooksUpdate?.Invoke(this, true);
}

return _projectCollection;
}

/// <summary>
Expand Down Expand Up @@ -396,7 +394,7 @@ public async void DeleteFieldBook()
}

//Refresh page
FillProjectCollectionAsync();
_ =FillProjectCollectionAsync();

}

Expand Down Expand Up @@ -713,8 +711,9 @@ public async void ProjectDeleteButton_TappedAsync(object sender, Windows.UI.Xaml
private void ViewModel_projectEdit(object sender)
{
//Refresh page
FillProjectCollectionAsync();
_ =FillProjectCollectionAsync();

RaisePropertyChanged("ProjectCollection");
}

/// <summary>
Expand Down Expand Up @@ -868,7 +867,7 @@ await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatch

SetFieldBook(restFieldBook);

FillProjectCollectionAsync();
_ = FillProjectCollectionAsync();
}
else
{
Expand Down Expand Up @@ -1149,7 +1148,7 @@ await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatch
private void upgradedDBDialog_Closed(ContentDialog sender, ContentDialogClosedEventArgs args)
{
//Send call to refresh other pages
FillProjectCollectionAsync();
_ = FillProjectCollectionAsync();
EventHandler<string> newFieldBookRequest = newFieldBookSelected;
if (newFieldBookRequest != null)
{
Expand Down

0 comments on commit 4d91395

Please sign in to comment.