Comments editor
This commit is contained in:
@@ -27,6 +27,7 @@ namespace FoxTube.Controls
|
||||
public sealed partial class CommentCard : UserControl
|
||||
{
|
||||
Comment item;
|
||||
CommentThread thread;
|
||||
CommentType type = CommentType.TopLevel;
|
||||
string NextPageToken;
|
||||
|
||||
@@ -39,6 +40,7 @@ namespace FoxTube.Controls
|
||||
public async void Initialize(CommentThread comment)
|
||||
{
|
||||
item = comment.Snippet.TopLevelComment;
|
||||
thread = comment;
|
||||
|
||||
replyBtn.Visibility = !comment.Snippet.CanReply.Value || !SecretsVault.IsAuthorized ? Visibility.Collapsed : Visibility.Visible;
|
||||
if (!comment.Snippet.TotalReplyCount.HasValue || comment.Snippet.TotalReplyCount.Value == 0)
|
||||
@@ -200,16 +202,37 @@ namespace FoxTube.Controls
|
||||
editor.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void editorSend_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(type == CommentType.Reply)
|
||||
private async void editorSend_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
editorText.IsEnabled = false;
|
||||
editorSend.IsEnabled = false;
|
||||
editorClose.IsEnabled = false;
|
||||
editorSending.Visibility = Visibility.Visible;
|
||||
|
||||
}
|
||||
try
|
||||
{
|
||||
item.Snippet.TextDisplay = editorText.Text;
|
||||
item.Snippet.UpdatedAt = DateTime.Now;
|
||||
|
||||
if (type == CommentType.Reply)
|
||||
await SecretsVault.Service.Comments.Update(item, "snippet").ExecuteAsync();
|
||||
else
|
||||
{
|
||||
|
||||
thread.Snippet.TopLevelComment = item;
|
||||
await SecretsVault.Service.CommentThreads.Update(thread, "snippet").ExecuteAsync();
|
||||
}
|
||||
|
||||
editorClose_Click(this, null);
|
||||
}
|
||||
catch
|
||||
{
|
||||
await new MessageDialog("Failed to edit your commentary. Please, try again later.", "Failed to edit your commentary").ShowAsync();
|
||||
}
|
||||
|
||||
editorText.IsEnabled = true;
|
||||
editorSend.IsEnabled = true;
|
||||
editorClose.IsEnabled = true;
|
||||
editorSending.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void editorText_TextChanged(object sender, TextChangedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user