More UI updates

This commit is contained in:
2023-04-16 12:57:17 -04:00
parent 5c0c84a068
commit d6a2fd5a46
47 changed files with 3695 additions and 3768 deletions

View File

@@ -2,28 +2,27 @@
using System.Collections.ObjectModel;
using System.Collections.Specialized;
namespace FeedCenter.Data
namespace FeedCenter.Data;
public class RealmObservableCollection<T> : ObservableCollection<T> where T : IRealmObject
{
public class RealmObservableCollection<T> : ObservableCollection<T> where T : IRealmObject
private readonly Realm _realm;
public RealmObservableCollection(Realm realm) : base(realm.All<T>())
{
private readonly Realm _realm;
_realm = realm;
}
public RealmObservableCollection(Realm realm) : base(realm.All<T>())
{
_realm = realm;
}
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
if (e.OldItems != null)
foreach (T item in e.OldItems)
_realm.Remove(item);
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
if (e.OldItems != null)
foreach (T item in e.OldItems)
_realm.Remove(item);
if (e.NewItems != null)
foreach (T item in e.NewItems)
_realm.Add(item);
if (e.NewItems != null)
foreach (T item in e.NewItems)
_realm.Add(item);
base.OnCollectionChanged(e);
}
base.OnCollectionChanged(e);
}
}