fix: reload favorites after modified
This commit is contained in:
parent
8a471b6272
commit
02ae52d5cc
@ -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<IllustItem> DoGetIllustList(IllustItem[] data)
|
||||
{
|
||||
return data;
|
||||
|
@ -695,12 +695,6 @@ namespace Pixiview.Illust
|
||||
}
|
||||
}
|
||||
|
||||
public class IllustFavorite
|
||||
{
|
||||
public DateTime LastFavoriteUtc { get; set; }
|
||||
public List<IllustItem> Illusts { get; set; }
|
||||
}
|
||||
|
||||
public enum IllustType
|
||||
{
|
||||
Illust = 0,
|
||||
|
@ -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;
|
||||
|
||||
|
@ -49,8 +49,9 @@ namespace Pixiview.Utils
|
||||
}
|
||||
}
|
||||
|
||||
public static List<IllustItem> 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<IllustItem>()
|
||||
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<IllustItem>
|
||||
{
|
||||
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";
|
||||
|
Loading…
x
Reference in New Issue
Block a user