public async Task RefreshDataFromCache(string grouping) { LoggingService.LogInformation("RefreshDataFromCache'", "YouTubeService.RefreshDataFromCache"); var foundPlaying = StandardFeedResults.Where(x => !string.IsNullOrEmpty(x.UIStateFull)); if (foundPlaying != null & foundPlaying.Count() > 0) { //StandardFeedResults.ToList().RemoveAll(x => x != foundPlaying.First()); var tempUIDs = StandardFeedResults.Where(x => string.IsNullOrEmpty(x.UIStateFull)).Select(x => x.Uid).ToArray(); string foundUID = foundPlaying.First().Uid; for (int i = 0; i < tempUIDs.Count(); i++) { //if (tempUIDs[i] != foundUID) StandardFeedResults.Remove(StandardFeedResults.Where(x => x.Uid == tempUIDs[i] && string.IsNullOrEmpty(x.UIStateFull)).First()); } } else { StandardFeedResults.Clear(); } var found = AppDatabase.Current.RetrieveYoutubePersistedItemByGrouping(grouping); if (found != null && found.Count > 0) { //StandardFeedResults.ToList().RemoveAll(x => x._Grouping == grouping); foreach (var item in found) { var ni = new YoutubeDataItem(item.Uid, item.Title, item.Subtitle, item.Image, item.Description, item.VideoId, null); ni.ImagePath = item.ImagePath; ni._Grouping = grouping; ni.NewUID = item.NewUID; StandardFeedResults.Add(ni); } return; } }
public async Task RefreshHistoryDataFromCache(string grouping) { try { //await Task.Run(() => //{ //await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => //{ LoggingService.LogInformation("RefreshDataFromCache'", "YouTubeService.RefreshDataFromCache"); var foundPlaying = StandardFeedResults.Where(x => !string.IsNullOrEmpty(x.UIStateFull)); if (foundPlaying != null & foundPlaying.Count() > 0) { //StandardFeedResults.ToList().RemoveAll(x => x != foundPlaying.First()); var tempUIDs = StandardFeedResults.Where(x => string.IsNullOrEmpty(x.UIStateFull)).Select(x => x.Uid).ToArray(); string foundUID = foundPlaying.First().Uid; for (int i = 0; i < tempUIDs.Count(); i++) { //if (tempUIDs[i] != foundUID) StandardFeedResults.Remove(StandardFeedResults.Where(x => x.Uid == tempUIDs[i] && string.IsNullOrEmpty(x.UIStateFull)).First()); } } else { StandardFeedResults.Clear(); } var found = AppDatabase.Current.RetrieveYoutubeHistoryItemByGrouping(grouping); if (found != null && found.Count > 0) { //StandardFeedResults.ToList().RemoveAll(x => x._Grouping == grouping); found.Reverse(); foreach (var item in found) { var ytdi = new YoutubeDataItem(item.Uid, item.Title, item.Subtitle, item.ImagePath, item.Description, item.VideoId, null); ytdi._Grouping = grouping; //if (StandardFeedResults.Count() == 0) StandardFeedResults.Add(ytdi); //else // StandardFeedResults.Insert(0, ytdi); } return; } //}); //}); } catch (Exception ex) { AlertService.LogAlertMessage("Error retrieving History from Cache", ex.Message); } return; }