diff --git a/Sources/Stim.Model/User.cs b/Sources/Stim.Model/User.cs index 3566534..7541656 100644 --- a/Sources/Stim.Model/User.cs +++ b/Sources/Stim.Model/User.cs @@ -81,15 +81,10 @@ namespace Model public event PropertyChangedEventHandler? PropertyChanged; - private void NotifyPropertyChanged([CallerMemberName] string propertyName = "") - => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + public ReadOnlyCollection Followed_Games => followed_Games.AsReadOnly(); [DataMember] - public ObservableCollection Followed_Games - { - get; - private init; - } + private readonly List followed_Games; public User(string userImage,string username, string biographie, string email, string password) { @@ -103,8 +98,11 @@ namespace Model else Email = email; if (password == null) throw new ArgumentNullException(nameof(password)); else Password = password; - Followed_Games = new ObservableCollection(); + followed_Games = new List(); } + private void NotifyPropertyChanged([CallerMemberName] string propertyName = "") + => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + public bool Equals(User? other) { if (string.IsNullOrWhiteSpace(Username)) return false; @@ -143,12 +141,12 @@ namespace Model public void FollowAGame(Game game) { if (Followed_Games.Contains(game)) return; - Followed_Games.Add(game); + followed_Games.Add(game); } public void RemoveAGame(Game game) { if (!Followed_Games.Contains(game)) return; - Followed_Games.Remove(game); + followed_Games.Remove(game); } public override string ToString() @@ -158,6 +156,5 @@ namespace Model foreach (Game game in Followed_Games) builder.Append($"{game.Name}\n"); return builder.ToString(); } - } } diff --git a/Sources/Stim/DetailledPage.xaml.cs b/Sources/Stim/DetailledPage.xaml.cs index f7c5d8a..6b8a9b6 100644 --- a/Sources/Stim/DetailledPage.xaml.cs +++ b/Sources/Stim/DetailledPage.xaml.cs @@ -53,6 +53,7 @@ public partial class DetailledPage : ContentPage { await this.ShowPopupAsync(new MessagePopup("Jeu ajouté dans les suivis !")); ((App)App.Current).Manager.CurrentUser.FollowAGame((App.Current as App).Manager.SelectedGame); + ((App)App.Current).Manager.SaveUser(); } else { diff --git a/Sources/Stim/ProfilPage.xaml.cs b/Sources/Stim/ProfilPage.xaml.cs index 20f6dff..e502c18 100644 --- a/Sources/Stim/ProfilPage.xaml.cs +++ b/Sources/Stim/ProfilPage.xaml.cs @@ -14,6 +14,7 @@ public partial class ProfilPage : ContentPage private void CollectionView_SelectionChanged(object sender, SelectionChangedEventArgs e) { ((App)App.Current).Manager.CurrentUser.RemoveAGame((sender as CollectionView).SelectedItem as Game); + ((App)App.Current).Manager.SaveUser(); } private async void ChangeUsername(object sender, EventArgs e)