diff --git a/FoxTube/Controls/CommentCard.xaml b/FoxTube/Controls/CommentCard.xaml
index 41d172f..d5040f7 100644
--- a/FoxTube/Controls/CommentCard.xaml
+++ b/FoxTube/Controls/CommentCard.xaml
@@ -12,8 +12,8 @@
-
-
+
+
@@ -63,15 +63,16 @@
-
-
+
diff --git a/FoxTube/Controls/CommentCard.xaml.cs b/FoxTube/Controls/CommentCard.xaml.cs
index a2597fa..3f26ea2 100644
--- a/FoxTube/Controls/CommentCard.xaml.cs
+++ b/FoxTube/Controls/CommentCard.xaml.cs
@@ -17,6 +17,7 @@ using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
using Windows.UI.Xaml.Media.Imaging;
using Windows.System;
+using Windows.UI.Popups;
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
@@ -37,7 +38,7 @@ namespace FoxTube.Controls
{
item = comment.Snippet.TopLevelComment;
- replyBtn.Visibility = comment.Snippet.CanReply == true ? Visibility.Visible : Visibility.Collapsed;
+ replyBtn.Visibility = !comment.Snippet.CanReply.Value || !SecretsVault.IsAuthorized ? Visibility.Collapsed : Visibility.Visible;
if (!comment.Snippet.TotalReplyCount.HasValue || comment.Snippet.TotalReplyCount.Value == 0)
showReplies.Visibility = Visibility.Collapsed;
else
@@ -130,11 +131,6 @@ namespace FoxTube.Controls
Methods.MainPage.GoToChannel(item.Snippet.AuthorChannelId.ToString().Split('"')[3]);
}
- private async void text_LinkClicked(object sender, Microsoft.Toolkit.Uwp.UI.Controls.LinkClickedEventArgs e)
- {
- await Launcher.LaunchUriAsync(new Uri(e.Link));
- }
-
private async void more_Click(object sender, RoutedEventArgs e)
{
more.Visibility = Visibility.Collapsed;
@@ -155,5 +151,40 @@ namespace FoxTube.Controls
}
moreLoading.Visibility = Visibility.Collapsed;
}
+
+ private void reply_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ if (reply.Text.Length == 0)
+ send.IsEnabled = false;
+ else
+ send.IsEnabled = true;
+ }
+
+ private async void send_Click(object sender, RoutedEventArgs e)
+ {
+ send.IsEnabled = false;
+ reply.IsEnabled = false;
+ sending.Visibility = Visibility.Visible;
+
+ Comment comment = new Comment();
+ comment.Snippet = new CommentSnippet();
+ comment.Snippet.TextOriginal = reply.Text;
+ comment.Snippet.ParentId = item.Id;
+
+ try
+ {
+ Comment response = await SecretsVault.Service.Comments.Insert(comment, "snippet").ExecuteAsync();
+ reply.Text = "";
+ grid.RowDefinitions[1].Height = new GridLength(0);
+ replies.Children.Add(new CommentCard(response));
+ }
+ catch
+ {
+ await new MessageDialog("Failed to send your reply. Please, try again later.", "Failed to send your reply").ShowAsync();
+ }
+ send.IsEnabled = true;
+ reply.IsEnabled = true;
+ sending.Visibility = Visibility.Collapsed;
+ }
}
}
diff --git a/FoxTube/Pages/CommentsPage.xaml b/FoxTube/Pages/CommentsPage.xaml
index 61cfb68..15f74bd 100644
--- a/FoxTube/Pages/CommentsPage.xaml
+++ b/FoxTube/Pages/CommentsPage.xaml
@@ -9,46 +9,45 @@
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
-
+
+
+
+
+
-
+
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FoxTube/Pages/CommentsPage.xaml.cs b/FoxTube/Pages/CommentsPage.xaml.cs
index 579e55c..3531cd8 100644
--- a/FoxTube/Pages/CommentsPage.xaml.cs
+++ b/FoxTube/Pages/CommentsPage.xaml.cs
@@ -16,6 +16,7 @@ using Windows.UI.Xaml.Navigation;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
using FoxTube.Controls;
+using Windows.UI.Popups;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
@@ -40,6 +41,9 @@ namespace FoxTube.Pages
{
threadId = video.Id;
+ if (!SecretsVault.IsAuthorized)
+ grid.RowDefinitions[0].Height = new GridLength(0);
+
counter.Text = string.Format("{0:0,0} Comments", video.Statistics.CommentCount);
var request = SecretsVault.NoAuthService.CommentThreads.List("snippet,replies");
@@ -133,5 +137,41 @@ namespace FoxTube.Pages
moreLoading.Visibility = Visibility.Collapsed;
}
}
+
+ private async void send_Click(object sender, RoutedEventArgs e)
+ {
+ if(newComment.Text.Length > 0)
+ {
+ newComment.IsEnabled = false;
+ send.IsEnabled = false;
+ sending.Visibility = Visibility.Visible;
+
+ CommentThread thread = new CommentThread();
+ thread.Snippet = new CommentThreadSnippet();
+
+ Comment comment = new Comment();
+ comment.Snippet = new CommentSnippet();
+ comment.Snippet.TextOriginal = newComment.Text;
+
+ thread.Snippet.VideoId = threadId;
+ thread.Snippet.TopLevelComment = comment;
+
+ try
+ {
+ CommentThread response = await SecretsVault.Service.CommentThreads.Insert(thread, "snippet").ExecuteAsync();
+ newComment.Text = "";
+ placeholder.Children.Insert(0, new CommentCard(response));
+ scroll.ChangeView(null, 0, null);
+ }
+ catch
+ {
+ await new MessageDialog("Failed to publish your comment. Please, try again later.", "Failed to publish your comment").ShowAsync();
+ }
+
+ newComment.IsEnabled = true;
+ send.IsEnabled = true;
+ sending.Visibility = Visibility.Collapsed;
+ }
+ }
}
}