58 lines
1.4 KiB
C#
58 lines
1.4 KiB
C#
using FoxTube.Attributes;
|
|
using FoxTube.Models;
|
|
using System.Linq;
|
|
using Windows.UI.Xaml.Controls;
|
|
using Windows.UI.Xaml.Navigation;
|
|
|
|
namespace FoxTube.Views
|
|
{
|
|
/// <summary>
|
|
/// User's subscriptions list
|
|
/// </summary>
|
|
[Refreshable]
|
|
public sealed partial class Subscriptions : Page
|
|
{
|
|
public Subscriptions()
|
|
{
|
|
InitializeComponent();
|
|
list.ItemsSource = UserManagement.CurrentUser.Subscriptions;
|
|
}
|
|
|
|
private void List_ItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
// TODO: Navigate to channel
|
|
}
|
|
|
|
private async void Unsubscribe(object sender, Windows.UI.Xaml.RoutedEventArgs e)
|
|
{
|
|
loadingScreen.IsLoading = true;
|
|
await UserManagement.CurrentUser.UpdateSubscriptionState((sender as Button).Tag as string);
|
|
list.ItemsSource = UserManagement.CurrentUser.Subscriptions;
|
|
loadingScreen.IsLoading = false;
|
|
}
|
|
|
|
protected override void OnNavigatedTo(NavigationEventArgs e)
|
|
{
|
|
base.OnNavigatedTo(e);
|
|
|
|
if (e.NavigationMode == NavigationMode.Refresh)
|
|
RefreshSubscriptions();
|
|
}
|
|
|
|
private void RefreshContainer_RefreshRequested(RefreshContainer sender, RefreshRequestedEventArgs args) =>
|
|
RefreshSubscriptions();
|
|
|
|
private async void RefreshSubscriptions()
|
|
{
|
|
loadingScreen.IsLoading = true;
|
|
|
|
await UserManagement.CurrentUser.LoadSubscriptions();
|
|
list.ItemsSource = UserManagement.CurrentUser.Subscriptions;
|
|
|
|
MainPage.Current.UpdateSubscriptions();
|
|
|
|
loadingScreen.IsLoading = false;
|
|
}
|
|
}
|
|
}
|