#142: Fixed
This commit is contained in:
@@ -77,6 +77,7 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<ProgressBar Grid.Row="2" VerticalAlignment="Bottom" IsIndeterminate="True" Visibility="Collapsed" Name="commentsLoading"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
@@ -91,9 +92,6 @@
|
|||||||
Content="" />
|
Content="" />
|
||||||
<ProgressBar Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" IsIndeterminate="True" Foreground="Red" Name="sending" Visibility="Collapsed"/>
|
<ProgressBar Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" IsIndeterminate="True" Foreground="Red" Name="sending" Visibility="Collapsed"/>
|
||||||
|
|
||||||
<StackPanel Grid.Row="2" Name="repliesPlaceholder">
|
<StackPanel Grid.Row="2" Margin="60,0,0,0" Name="replies"/>
|
||||||
<StackPanel Margin="60,0,0,0" Name="replies"/>
|
|
||||||
<local:ShowMore Clicked="more_Click"/>
|
|
||||||
</StackPanel>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -26,21 +26,18 @@ namespace FoxTube.Controls
|
|||||||
public enum CommentType { TopLevel, Reply }
|
public enum CommentType { TopLevel, Reply }
|
||||||
public sealed partial class CommentCard : UserControl
|
public sealed partial class CommentCard : UserControl
|
||||||
{
|
{
|
||||||
ShowMore more;
|
|
||||||
|
|
||||||
Comment item;
|
Comment item;
|
||||||
CommentThread thread;
|
CommentThread thread;
|
||||||
|
bool repliesLoaded = false;
|
||||||
CommentType type = CommentType.TopLevel;
|
CommentType type = CommentType.TopLevel;
|
||||||
string NextPageToken;
|
|
||||||
|
|
||||||
public CommentCard(CommentThread comment)
|
public CommentCard(CommentThread comment)
|
||||||
{
|
{
|
||||||
this.InitializeComponent();
|
this.InitializeComponent();
|
||||||
more = repliesPlaceholder.Children[1] as ShowMore;
|
|
||||||
Initialize(comment);
|
Initialize(comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void Initialize(CommentThread comment)
|
public void Initialize(CommentThread comment)
|
||||||
{
|
{
|
||||||
item = comment.Snippet.TopLevelComment;
|
item = comment.Snippet.TopLevelComment;
|
||||||
thread = comment;
|
thread = comment;
|
||||||
@@ -67,24 +64,6 @@ namespace FoxTube.Controls
|
|||||||
|
|
||||||
try { avatar.ProfilePicture = new BitmapImage(new Uri(comment.Snippet.TopLevelComment.Snippet.AuthorProfileImageUrl)); }
|
try { avatar.ProfilePicture = new BitmapImage(new Uri(comment.Snippet.TopLevelComment.Snippet.AuthorProfileImageUrl)); }
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
if(comment.Snippet.TotalReplyCount > 0)
|
|
||||||
{
|
|
||||||
var request = SecretsVault.Service.Comments.List("snippet");
|
|
||||||
request.ParentId = item.Id;
|
|
||||||
request.TextFormat = CommentsResource.ListRequest.TextFormatEnum.PlainText;
|
|
||||||
request.MaxResults = 10;
|
|
||||||
|
|
||||||
var response = await request.ExecuteAsync();
|
|
||||||
|
|
||||||
if (response.NextPageToken != null)
|
|
||||||
NextPageToken = response.NextPageToken;
|
|
||||||
else
|
|
||||||
more.Visibility = Visibility.Collapsed;
|
|
||||||
|
|
||||||
foreach (Comment c in response.Items.Reverse())
|
|
||||||
replies.Children.Add(new CommentCard(c));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommentCard(Comment comment)
|
public CommentCard(Comment comment)
|
||||||
@@ -125,10 +104,45 @@ namespace FoxTube.Controls
|
|||||||
grid.RowDefinitions[1].Height = new GridLength(0);
|
grid.RowDefinitions[1].Height = new GridLength(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showReplies_Click(object sender, RoutedEventArgs e)
|
private async void showReplies_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (grid.RowDefinitions[2].Height == new GridLength(0))
|
if (grid.RowDefinitions[2].Height == new GridLength(0))
|
||||||
|
{
|
||||||
|
if(type == CommentType.TopLevel && !repliesLoaded)
|
||||||
|
{
|
||||||
|
commentsLoading.Visibility = Visibility.Visible;
|
||||||
|
var request = SecretsVault.Service.Comments.List("snippet");
|
||||||
|
request.ParentId = item.Id;
|
||||||
|
request.TextFormat = CommentsResource.ListRequest.TextFormatEnum.PlainText;
|
||||||
|
request.MaxResults = 50;
|
||||||
|
|
||||||
|
string token;
|
||||||
|
IList<Comment> list = new List<Comment>();
|
||||||
|
|
||||||
|
var response = await request.ExecuteAsync();
|
||||||
|
token = response.NextPageToken;
|
||||||
|
|
||||||
|
foreach (Comment i in response.Items)
|
||||||
|
list.Add(i);
|
||||||
|
|
||||||
|
while(token != null)
|
||||||
|
{
|
||||||
|
request.PageToken = token;
|
||||||
|
response = await request.ExecuteAsync();
|
||||||
|
token = response.NextPageToken;
|
||||||
|
|
||||||
|
foreach (Comment i in response.Items)
|
||||||
|
list.Add(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (Comment c in list.Reverse())
|
||||||
|
replies.Children.Add(new CommentCard(c));
|
||||||
|
|
||||||
|
repliesLoaded = true;
|
||||||
|
commentsLoading.Visibility = Visibility.Collapsed;
|
||||||
|
}
|
||||||
grid.RowDefinitions[2].Height = GridLength.Auto;
|
grid.RowDefinitions[2].Height = GridLength.Auto;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
grid.RowDefinitions[2].Height = new GridLength(0);
|
grid.RowDefinitions[2].Height = new GridLength(0);
|
||||||
}
|
}
|
||||||
@@ -138,27 +152,6 @@ namespace FoxTube.Controls
|
|||||||
Methods.MainPage.GoToChannel(item.Snippet.AuthorChannelId.ToString().Split('"')[3]);
|
Methods.MainPage.GoToChannel(item.Snippet.AuthorChannelId.ToString().Split('"')[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void more_Click()
|
|
||||||
{
|
|
||||||
var request = SecretsVault.NoAuthService.Comments.List("snippet");
|
|
||||||
request.ParentId = item.Id;
|
|
||||||
request.MaxResults = 10;
|
|
||||||
request.PageToken = NextPageToken;
|
|
||||||
request.TextFormat = CommentsResource.ListRequest.TextFormatEnum.PlainText;
|
|
||||||
var response = await request.ExecuteAsync();
|
|
||||||
|
|
||||||
foreach (Comment c in response.Items.Reverse())
|
|
||||||
replies.Children.Add(new CommentCard(c));
|
|
||||||
|
|
||||||
if (response.NextPageToken != null)
|
|
||||||
{
|
|
||||||
NextPageToken = response.NextPageToken;
|
|
||||||
more.Complete();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
more.Complete(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void reply_TextChanged(object sender, TextChangedEventArgs e)
|
private void reply_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (reply.Text.Length == 0)
|
if (reply.Text.Length == 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user