From 7597981420e4d517505c5b400984dfbd7ac55eea Mon Sep 17 00:00:00 2001 From: Michael Gordeev Date: Fri, 14 Dec 2018 12:49:55 +0300 Subject: [PATCH] #124: Done --- FoxTube.Background/BackgroundProcessor.cs | 9 ++++----- FoxTube/Pages/MainPage.xaml.cs | 18 ------------------ 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/FoxTube.Background/BackgroundProcessor.cs b/FoxTube.Background/BackgroundProcessor.cs index 1f60603..51ca404 100644 --- a/FoxTube.Background/BackgroundProcessor.cs +++ b/FoxTube.Background/BackgroundProcessor.cs @@ -4,6 +4,7 @@ using Google.Apis.YouTube.v3.Data; using Newtonsoft.Json; using System; using System.Collections.Generic; +using System.Threading.Tasks; using System.Xml; using Windows.ApplicationModel.Background; using Windows.Storage; @@ -37,13 +38,11 @@ namespace FoxTube.Background else lastCheck = DateTime.Parse(settings.Values["lastCheck"] as string); - //ToastNotificationManager.CreateToastNotifier().Show(Notification.GetInternalToast(null, $"{DateTime.Now} Retrieving videos since", lastCheck.ToString(), null, null)); - bool[] notificationsSettings = JsonConvert.DeserializeObject(await FileIO.ReadTextAsync(await ApplicationData.Current.RoamingFolder.GetFileAsync("notifications.json"))); if (notificationsSettings[0]) CheckAnnouncements(); if (notificationsSettings[1]) - CheckAccount(); + await CheckAccount(); } catch { } finally @@ -53,7 +52,7 @@ namespace FoxTube.Background } } - async void CheckAccount() + async Task CheckAccount() { try { @@ -61,7 +60,7 @@ namespace FoxTube.Background foreach (var s in subscriptions) { SearchResource.ListRequest request = Service.Search.List("snippet"); - request.PublishedAfter = lastCheck.Subtract(TimeSpan.FromDays(1)); + request.PublishedAfter = lastCheck; request.ChannelId = s.Key; request.Type = "video"; request.MaxResults = 5; diff --git a/FoxTube/Pages/MainPage.xaml.cs b/FoxTube/Pages/MainPage.xaml.cs index 0b9d07d..c2e7eab 100644 --- a/FoxTube/Pages/MainPage.xaml.cs +++ b/FoxTube/Pages/MainPage.xaml.cs @@ -102,24 +102,6 @@ namespace FoxTube Initialize(); } - async void GetVideosFromToday() - { - foreach (Subscription i in SecretsVault.Subscriptions) - { - SearchResource.ListRequest request = SecretsVault.NoAuthService.Search.List("snippet"); - request.PublishedAfter = DateTime.Now.Subtract(TimeSpan.FromDays(1)); - Debug.WriteLine(DateTime.Now.Subtract(TimeSpan.FromDays(1))); - request.ChannelId = i.Snippet.ResourceId.ChannelId; - request.Type = "video"; - request.MaxResults = 5; - SearchListResponse response = await request.ExecuteAsync(); - - foreach (SearchResult result in response.Items) - ToastNotificationManager.CreateToastNotifier().Show( - FoxTube.Background.Notification.GetVideoToast(result.Id.VideoId, result.Snippet.ChannelId, result.Snippet.Title, result.Snippet.ChannelTitle, result.Snippet.Thumbnails.Medium.Url, i.Snippet.Thumbnails.Medium.Url)); - } - } - public async void Initialize() { bool[] notificationsSettings = new bool[] { (bool)settings.Values["newVideoNotification"], (bool)settings.Values["devNews"] };