Added "Delete playlist item" to video cards on playlist page
Related Work Items: #192
This commit is contained in:
@@ -4,7 +4,6 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:Windows10version1809="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 7)"
|
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
@@ -90,7 +89,7 @@
|
|||||||
<ToggleMenuFlyoutItem Text="Watch later" Name="wl" Click="Wl_Click" Icon="Clock"/>
|
<ToggleMenuFlyoutItem Text="Watch later" Name="wl" Click="Wl_Click" Icon="Clock"/>
|
||||||
<MenuFlyoutSeparator/>
|
<MenuFlyoutSeparator/>
|
||||||
</MenuFlyoutSubItem>
|
</MenuFlyoutSubItem>
|
||||||
<MenuFlyoutItem Text="Remove from playlist" Icon="Delete" Visibility="Collapsed"/>
|
<MenuFlyoutItem Text="Remove from playlist" Icon="Delete" Visibility="Collapsed" Name="delete" Click="Delete_Click"/>
|
||||||
</MenuFlyout>
|
</MenuFlyout>
|
||||||
</UserControl.ContextFlyout>
|
</UserControl.ContextFlyout>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using YoutubeExplode;
|
|||||||
using Windows.UI.Popups;
|
using Windows.UI.Popups;
|
||||||
using YoutubeExplode.Models.MediaStreams;
|
using YoutubeExplode.Models.MediaStreams;
|
||||||
using Windows.Foundation;
|
using Windows.Foundation;
|
||||||
|
using FoxTube.Pages;
|
||||||
|
|
||||||
namespace FoxTube.Controls
|
namespace FoxTube.Controls
|
||||||
{
|
{
|
||||||
@@ -48,6 +49,8 @@ namespace FoxTube.Controls
|
|||||||
videoId = id;
|
videoId = id;
|
||||||
playlistId = playlist;
|
playlistId = playlist;
|
||||||
|
|
||||||
|
delete.Visibility = string.IsNullOrWhiteSpace(playlistId) ? Visibility.Collapsed : Visibility.Visible;
|
||||||
|
|
||||||
VideosResource.ListRequest request = SecretsVault.Service.Videos.List("snippet,contentDetails,statistics,liveStreamingDetails");
|
VideosResource.ListRequest request = SecretsVault.Service.Videos.List("snippet,contentDetails,statistics,liveStreamingDetails");
|
||||||
request.Id = id;
|
request.Id = id;
|
||||||
item = (await request.ExecuteAsync()).Items[0];
|
item = (await request.ExecuteAsync()).Items[0];
|
||||||
@@ -444,5 +447,26 @@ namespace FoxTube.Controls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void Delete_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
PlaylistItemsResource.ListRequest request = SecretsVault.Service.PlaylistItems.List("snippet");
|
||||||
|
request.PlaylistId = playlistId;
|
||||||
|
request.VideoId = item.Id;
|
||||||
|
PlaylistItemListResponse response = await request.ExecuteAsync();
|
||||||
|
|
||||||
|
PlaylistItem playlistItem = response.Items.Find(i => i.Snippet.PlaylistId == playlistId);
|
||||||
|
|
||||||
|
await SecretsVault.Service.PlaylistItems.Delete(playlistItem.Id).ExecuteAsync();
|
||||||
|
|
||||||
|
(Methods.MainPage.PageContent as PlaylistPage).DeleteItem(this);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ namespace FoxTube
|
|||||||
public static event ObjectEventHandler VideoPageSizeChanged;
|
public static event ObjectEventHandler VideoPageSizeChanged;
|
||||||
readonly ResourceLoader resources = ResourceLoader.GetForCurrentView("Main");
|
readonly ResourceLoader resources = ResourceLoader.GetForCurrentView("Main");
|
||||||
Dictionary<Type, Action> headers;
|
Dictionary<Type, Action> headers;
|
||||||
|
|
||||||
|
public Page PageContent => content.Content as Page;
|
||||||
|
|
||||||
public MainPage()
|
public MainPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|||||||
@@ -147,5 +147,10 @@ namespace FoxTube.Pages
|
|||||||
foreach (PlaylistItem i in response.Items)
|
foreach (PlaylistItem i in response.Items)
|
||||||
list.Add(new VideoCard(i.ContentDetails.VideoId, playlistId));
|
list.Add(new VideoCard(i.ContentDetails.VideoId, playlistId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DeleteItem(FrameworkElement card)
|
||||||
|
{
|
||||||
|
list.DeleteItem(card);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,12 @@ namespace FoxTube.Pages
|
|||||||
empty.Visibility = Visibility.Visible;
|
empty.Visibility = Visibility.Visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DeleteItem(FrameworkElement item)
|
||||||
|
{
|
||||||
|
Children.Remove(item);
|
||||||
|
UpdateGrid();
|
||||||
|
}
|
||||||
|
|
||||||
void UpdateGrid()
|
void UpdateGrid()
|
||||||
{
|
{
|
||||||
for (int k = 1; k <= 5; k++)
|
for (int k = 1; k <= 5; k++)
|
||||||
|
|||||||
Reference in New Issue
Block a user