diff --git a/FoxTube/App.xaml.cs b/FoxTube/App.xaml.cs index acc846c..0bfc754 100644 --- a/FoxTube/App.xaml.cs +++ b/FoxTube/App.xaml.cs @@ -260,20 +260,21 @@ namespace FoxTube /// /// The source of the suspend request. /// Details about the suspend request. - private async void OnSuspending(object sender, SuspendingEventArgs e) + private void OnSuspending(object sender, SuspendingEventArgs e) { var deferral = e.SuspendingOperation.GetDeferral(); - //await new MessageDialog("suspending").ShowAsync(); + //Saving history - await FileIO.WriteTextAsync( + /*await FileIO.WriteTextAsync( await ApplicationData.Current.RoamingFolder.CreateFileAsync("history.json", CreationCollisionOption.ReplaceExisting), JsonConvert.SerializeObject(SecretsVault.UserHistory)); //Saving WL playlist await FileIO.WriteTextAsync( await ApplicationData.Current.RoamingFolder.CreateFileAsync("watchlater.json", CreationCollisionOption.ReplaceExisting), - JsonConvert.SerializeObject(SecretsVault.WatchLater)); + JsonConvert.SerializeObject(SecretsVault.WatchLater));*/ //Saving downloads Methods.MainPage.Agent.QuitPrompt(); + ToastNotificationManager.CreateToastNotifier().Show(Background.Notification.GetInternalToast(null, "All data saved", "", null, null)); deferral.Complete(); } } diff --git a/FoxTube/Classes/DownloadAgent.cs b/FoxTube/Classes/DownloadAgent.cs index 7469530..6fb413b 100644 --- a/FoxTube/Classes/DownloadAgent.cs +++ b/FoxTube/Classes/DownloadAgent.cs @@ -52,29 +52,19 @@ namespace FoxTube.Controls items.Remove(item); } - public void QuitPrompt() + public async void QuitPrompt() { - if(items.Exists(x => x.InProgress)) - { - MessageDialog dialog = new MessageDialog($"Waiting pending downloads ({items.FindAll(x => x.InProgress).Count})..."); + foreach (DownloadItem i in items.FindAll(x => x.InProgress)) + i.Cancel(); + items.RemoveAll(x => x.InProgress); - dialog.Commands.Add(new UICommand("Force quit", async (command) => - { - foreach (DownloadItem i in items.FindAll(x => x.InProgress)) - i.Cancel(); - items.RemoveAll(x => x.InProgress); + List containers = new List(); + foreach (DownloadItem i in items) + containers.Add(i.Container); - List containers = new List(); - foreach (DownloadItem i in items) - containers.Add(i.Container); - - await FileIO.WriteTextAsync( - await roaming.CreateFileAsync("downloads.json", CreationCollisionOption.ReplaceExisting), - JsonConvert.SerializeObject(containers)); - })); - - prompt = dialog.ShowAsync(); - } + await FileIO.WriteTextAsync( + await roaming.CreateFileAsync("downloads.json", CreationCollisionOption.ReplaceExisting), + JsonConvert.SerializeObject(containers)); } } } diff --git a/FoxTube/Classes/SecretsVault.cs b/FoxTube/Classes/SecretsVault.cs index f8fdb78..53a452a 100644 --- a/FoxTube/Classes/SecretsVault.cs +++ b/FoxTube/Classes/SecretsVault.cs @@ -16,7 +16,7 @@ using Windows.UI.Popups; namespace FoxTube { - public class HistoryItem + /*public class HistoryItem { public string Id { get; set; } public double LeftOn { get; set; } @@ -32,7 +32,7 @@ namespace FoxTube Id = id; LeftOn = 0; } - } + }*/ public static class SecretsVault { @@ -57,8 +57,8 @@ namespace FoxTube public static bool IsAuthorized { get; private set; } = false; public static Channel UserChannel { get; private set; } - public static List WatchLater { get; private set; } = new List(); - public static List UserHistory { get; private set; } = new List(); + /*public static List WatchLater { get; private set; } = new List(); + public static List UserHistory { get; private set; } = new List();*/ public static List Subscriptions { get; private set; } = new List(); public static YouTubeService NoAuthService => new YouTubeService(new BaseClientService.Initializer() @@ -77,14 +77,14 @@ namespace FoxTube } } - public static void HistoryAdd(string id, TimeSpan elapsed, TimeSpan total) + /*public static void HistoryAdd(string id, TimeSpan elapsed, TimeSpan total) { UserHistory.Remove(UserHistory.Find(x => x.Id == id)); UserHistory.Add(new HistoryItem(id, elapsed, total)); if (UserHistory.Count > 100) UserHistory.RemoveAt(UserHistory.Count - 1); - } + }*/ public static async Task ChangeSubscriptionState(string id) { @@ -208,7 +208,7 @@ namespace FoxTube UserChannel = (await request.ExecuteAsync()).Items[0]; AccountId = UserChannel.Id; - try + /*try { await ApplicationData.Current.RoamingFolder.GetFileAsync("history.json"); UserHistory = JsonConvert.DeserializeObject>(await FileIO.ReadTextAsync(await ApplicationData.Current.RoamingFolder.GetFileAsync("history.json"))); @@ -231,7 +231,7 @@ namespace FoxTube await ApplicationData.Current.RoamingFolder.CreateFileAsync("watchlater.json", CreationCollisionOption.ReplaceExisting), JsonConvert.SerializeObject(new List())); WatchLater = new List(); - } + }*/ /*PlaylistItemsResource.ListRequest playlistRequest = Service.PlaylistItems.List("snippet"); playlistRequest.PlaylistId = UserChannel.ContentDetails.RelatedPlaylists.WatchHistory; diff --git a/FoxTube/Controls/VideoCard.xaml.cs b/FoxTube/Controls/VideoCard.xaml.cs index 23a4cae..4ad9977 100644 --- a/FoxTube/Controls/VideoCard.xaml.cs +++ b/FoxTube/Controls/VideoCard.xaml.cs @@ -30,9 +30,7 @@ namespace FoxTube.Controls public async void Initialize(string id, string playlist = null) { - YouTubeService ytService = SecretsVault.NoAuthService; - - VideosResource.ListRequest request = ytService.Videos.List("snippet,contentDetails,statistics,liveStreamingDetails"); + VideosResource.ListRequest request = SecretsVault.Service.Videos.List("snippet,contentDetails,statistics,liveStreamingDetails"); request.Id = id; VideoListResponse response = await request.ExecuteAsync(); @@ -71,7 +69,7 @@ namespace FoxTube.Controls embed = false; } - var request1 = ytService.Channels.List("snippet"); + var request1 = SecretsVault.Service.Channels.List("snippet"); request1.Id = item.Snippet.ChannelId; ChannelListResponse response1 = await request1.ExecuteAsync(); @@ -82,11 +80,11 @@ namespace FoxTube.Controls } catch { } - if(SecretsVault.UserHistory.Exists(x => x.Id == videoId)) + /*if(SecretsVault.UserHistory.Exists(x => x.Id == videoId)) { watched.Visibility = Visibility.Visible; leftOn.Value = SecretsVault.UserHistory.Find(x => x.Id == videoId).LeftOn; - } + }*/ } public async void Button_Click(object sender, RoutedEventArgs e) diff --git a/FoxTube/Controls/VideoPlayer.xaml.cs b/FoxTube/Controls/VideoPlayer.xaml.cs index 64052d2..72bc6d3 100644 --- a/FoxTube/Controls/VideoPlayer.xaml.cs +++ b/FoxTube/Controls/VideoPlayer.xaml.cs @@ -203,7 +203,7 @@ namespace FoxTube systemControls.ButtonPressed += SystemControls_Engaged; systemControls.IsEnabled = true; - SecretsVault.HistoryAdd(videoId, elapsed, total); + //SecretsVault.HistoryAdd(videoId, elapsed, total); t.Start(); @@ -615,7 +615,7 @@ namespace FoxTube break; } - SecretsVault.HistoryAdd(videoId, elapsed, total); + //SecretsVault.HistoryAdd(videoId, elapsed, total); } private async void miniView_Click(object sender, RoutedEventArgs e) diff --git a/FoxTube/Pages/History.xaml b/FoxTube/Pages/History.xaml index e618e2f..5f274ca 100644 --- a/FoxTube/Pages/History.xaml +++ b/FoxTube/Pages/History.xaml @@ -20,7 +20,7 @@ - + diff --git a/FoxTube/Pages/History.xaml.cs b/FoxTube/Pages/History.xaml.cs index 7565c21..6211a17 100644 --- a/FoxTube/Pages/History.xaml.cs +++ b/FoxTube/Pages/History.xaml.cs @@ -34,10 +34,7 @@ namespace FoxTube.Pages public void Initialize() { loading.Refresh(); - - list.Clear(); - SecretsVault.UserHistory.ForEach(i => list.Add(new VideoCard(i.Id))); - + loading.Close(); } @@ -46,9 +43,9 @@ namespace FoxTube.Pages await Launcher.LaunchUriAsync(new Uri("youtube.com/feed/history")); } - private void help_Click(object sender, RoutedEventArgs e) + private void Refresh_Click(object sender, RoutedEventArgs e) { - Methods.MainPage.GoToDeveloper("local-history"); + } } } diff --git a/FoxTube/Pages/Subscriptions.xaml b/FoxTube/Pages/Subscriptions.xaml index 2a9729b..984d428 100644 --- a/FoxTube/Pages/Subscriptions.xaml +++ b/FoxTube/Pages/Subscriptions.xaml @@ -15,7 +15,7 @@ -