diff --git a/Pixiview/Illust/FavoritesPage.xaml.cs b/Pixiview/Illust/FavoritesPage.xaml.cs index ba39843..5427292 100644 --- a/Pixiview/Illust/FavoritesPage.xaml.cs +++ b/Pixiview/Illust/FavoritesPage.xaml.cs @@ -21,6 +21,24 @@ namespace Pixiview.Illust protected override ActivityIndicator LoadingIndicator => activityLoading; protected override bool IsDelayLoading => true; + protected override void OnAppearing() + { + if (lastUpdated != LastUpdated) + { + StartLoad(); + } + else + { + var favorites = Stores.Favorites; + if (favorites.Changed) + { + favorites.Reload(); + lastUpdated = default; + StartLoad(); + } + } + } + protected override IEnumerable DoGetIllustList(IllustItem[] data) { return data; diff --git a/Pixiview/Illust/IllustCollectionPage.cs b/Pixiview/Illust/IllustCollectionPage.cs index e7e1302..709165f 100644 --- a/Pixiview/Illust/IllustCollectionPage.cs +++ b/Pixiview/Illust/IllustCollectionPage.cs @@ -695,12 +695,6 @@ namespace Pixiview.Illust } } - public class IllustFavorite - { - public DateTime LastFavoriteUtc { get; set; } - public List Illusts { get; set; } - } - public enum IllustType { Illust = 0, diff --git a/Pixiview/Illust/ViewIllustPage.xaml.cs b/Pixiview/Illust/ViewIllustPage.xaml.cs index 13931ac..c160511 100644 --- a/Pixiview/Illust/ViewIllustPage.xaml.cs +++ b/Pixiview/Illust/ViewIllustPage.xaml.cs @@ -135,8 +135,7 @@ namespace Pixiview.Illust fontIconLove = (ImageSource)Application.Current.Resources[ThemeBase.FontIconLove]; fontIconNotLove = (ImageSource)Application.Current.Resources[ThemeBase.FontIconNotLove]; - var favorites = Stores.Favorites; - FavoriteIcon = favorites.Any(i => i.Id == illust.Id) + FavoriteIcon = Stores.Favorites.Any(i => i.Id == illust.Id) ? fontIconLove : fontIconNotLove; diff --git a/Pixiview/Utils/Stores.cs b/Pixiview/Utils/Stores.cs index b7ad256..47caeb0 100644 --- a/Pixiview/Utils/Stores.cs +++ b/Pixiview/Utils/Stores.cs @@ -49,8 +49,9 @@ namespace Pixiview.Utils } } - public static List Favorites => GetFavoriteObject().Illusts; + public static FavoriteList Favorites => GetFavoriteObject().Illusts; public static string FavoritesPath => Path.Combine(PersonalFolder, favoriteFile); + public static DateTime FavoritesLastUpdated { get; set; } = DateTime.Now; private static IllustFavorite favoriteObject; @@ -69,7 +70,7 @@ namespace Pixiview.Utils { favoriteObject = new IllustFavorite { - Illusts = new List() + Illusts = new FavoriteList() }; } } @@ -450,6 +451,34 @@ namespace Pixiview.Utils } } + public class IllustFavorite + { + public DateTime LastFavoriteUtc { get; set; } + public FavoriteList Illusts { get; set; } + } + + public class FavoriteList : List + { + public bool Changed { get; private set; } + + public new void Insert(int index, IllustItem item) + { + base.Insert(index, item); + Changed = true; + } + + public new void RemoveAt(int index) + { + base.RemoveAt(index); + Changed = true; + } + + public void Reload() + { + Changed = false; + } + } + public static class Configs { public const string IsOnR18Key = "is_on_r18";