public async Task UpdateRecentViewAsync() { if (IsLoading || !App.IsHistoryListChanged) return; LoadingText = "updating recent data..."; IsLoading = true; if (HistoryViewList == null) HistoryViewList = new ObservableCollection<HistoryItemViewModel>(); if (App.HistoryList == null) await App.LoadHistoryDataAsync(); var historyList = App.HistoryList; HistoryViewList.Clear(); for (int idx = historyList.Count - 1; idx >= 0; idx--) { var item = historyList[idx]; var hvm = new HistoryItemViewModel { Position = item.Position, ProgressPercentage = item.Progress, CoverImageUri = item.DescriptionImageUri, Description = item.ContentDescription, ChapterTitle = item.ChapterTitle, VolumeTitle = item.VolumeTitle, SeriesTitle = item.SeriesTitle, UpdateTime = item.ViewDate }; HistoryViewList.Add(hvm); //if (String.IsNullOrWhiteSpace(item.Position.VolumeId)) continue; //var series = await LightKindomHtmlClient.GetSeriesAsync(item.Position.SeriesId); ////var volume = await LightKindomHtmlClient.GetVolumeAsync(item.Position.VolumeId); //var volume = series.Volumes.First(vol => vol.Id == item.Position.VolumeId); //hvm.SeriesTitle = series.Title; //hvm.CoverImageUri = volume.CoverImageUri; //hvm.VolumeTitle = volume.Title; //hvm.ChapterTitle = volume.ChapterList[item.Position.ChapterNumber]; } var mainTile = ShellTile.ActiveTiles.FirstOrDefault(); if (mainTile != null && historyList.Count > 0) { var latestItem = historyList[historyList.Count - 1]; var imageUri = new Uri(latestItem.DescriptionImageUri); var data = new FlipTileData { SmallBackgroundImage = imageUri, BackgroundImage = imageUri, Title = "Light Novel", BackTitle = latestItem.VolumeTitle, BackContent = latestItem.ContentDescription, }; mainTile.Update(data); CoverBackgroundImageUri = imageUri; } App.IsHistoryListChanged = false; IsLoading = false; IsRecentDataLoaded = true; }
private async Task RemoveBookmarkFromFavorite(HistoryItemViewModel hvm) { ViewModel.IsLoading = true; ViewModel.FavoriteSection.Remove(hvm); try { var idx = AppGlobal.BookmarkList.FindIndex(bk => bk.SeriesTitle == hvm.SeriesTitle); if (idx >= 0) { AppGlobal.BookmarkList.RemoveAt(idx); await AppGlobal.SaveBookmarkDataAsync(); } if (AppGlobal.IsSignedIn) { var favDeSer = (from fav in AppGlobal.User.FavoriteList where fav.SeriesTitle == hvm.SeriesTitle select fav.FavId).ToArray(); if (favDeSer.Any(id => id == null)) { await AppGlobal.User.SyncFavoriteListAsync(true); (from fav in AppGlobal.User.FavoriteList where fav.SeriesTitle == hvm.SeriesTitle select fav.FavId).ToArray(); } await AppGlobal.User.RemoveUserFavriteAsync(favDeSer); } } catch (Exception) { Debug.WriteLine("Exception happens when deleting favorite"); } //ViewModel.FavoriteSection.NotifyPropertyChanged("IsEmpty"); ViewModel.IsLoading = false; }
public async Task UpdateRecentViewAsync() { if (IsLoading || !App.IsHistoryListChanged) { return; } LoadingText = "updating recent data..."; IsLoading = true; if (HistoryViewList == null) { HistoryViewList = new ObservableCollection <HistoryItemViewModel>(); } if (App.HistoryList == null) { await App.LoadHistoryDataAsync(); } var historyList = App.HistoryList; HistoryViewList.Clear(); for (int idx = historyList.Count - 1; idx >= 0; idx--) { var item = historyList[idx]; var hvm = new HistoryItemViewModel { Position = item.Position, ProgressPercentage = item.Progress, CoverImageUri = item.DescriptionImageUri, Description = item.ContentDescription, ChapterTitle = item.ChapterTitle, VolumeTitle = item.VolumeTitle, SeriesTitle = item.SeriesTitle, UpdateTime = item.ViewDate }; HistoryViewList.Add(hvm); //if (String.IsNullOrWhiteSpace(item.Position.VolumeId)) continue; //var series = await LightKindomHtmlClient.GetSeriesAsync(item.Position.SeriesId); ////var volume = await LightKindomHtmlClient.GetVolumeAsync(item.Position.VolumeId); //var volume = series.Volumes.First(vol => vol.Id == item.Position.VolumeId); //hvm.SeriesTitle = series.Title; //hvm.CoverImageUri = volume.CoverImageUri; //hvm.VolumeTitle = volume.Title; //hvm.ChapterTitle = volume.ChapterList[item.Position.ChapterNumber]; } var mainTile = ShellTile.ActiveTiles.FirstOrDefault(); if (mainTile != null && historyList.Count > 0) { var latestItem = historyList[historyList.Count - 1]; var imageUri = new Uri(latestItem.DescriptionImageUri); var data = new FlipTileData { SmallBackgroundImage = imageUri, BackgroundImage = imageUri, Title = "Light Novel", BackTitle = latestItem.VolumeTitle, BackContent = latestItem.ContentDescription, }; mainTile.Update(data); CoverBackgroundImageUri = imageUri; } App.IsHistoryListChanged = false; IsLoading = false; IsRecentDataLoaded = true; }
private async Task RemoveRecentItem(HistoryItemViewModel hvm) { ViewModel.IsLoading = true; await CachedClient.DeleteSeries(hvm.Position.SeriesId); ViewModel.RecentSection.Remove(hvm); var recentItem = AppGlobal.RecentList.FirstOrDefault(it => it.Position.SeriesId == hvm.Position.SeriesId); if (recentItem != null) { AppGlobal.RecentList.Remove(recentItem); await AppGlobal.SaveHistoryDataAsync(); } ViewModel.IsLoading = false; }