Archived
1
0
This commit is contained in:
Michael Gordeev
2018-09-22 23:07:10 +03:00
parent 10a6f028c0
commit 8bb0a0e11b
4 changed files with 50 additions and 30 deletions
+1
View File
@@ -14,6 +14,7 @@ namespace FoxTube
{ {
public static class Methods public static class Methods
{ {
public static bool NeedToResponse { get; set; } = false;
public static MainPage MainPage public static MainPage MainPage
{ {
get { return (Window.Current.Content as Frame).Content as MainPage; } get { return (Window.Current.Content as Frame).Content as MainPage; }
+3 -3
View File
@@ -86,6 +86,9 @@ namespace FoxTube.Pages
try try
{ {
channelId = id; channelId = id;
if (Methods.NeedToResponse)
Methods.MainPage.content_Navigated(this, null);
ChannelsResource.ListRequest request = SecretsVault.Service.Channels.List("snippet,statistics,brandingSettings"); ChannelsResource.ListRequest request = SecretsVault.Service.Channels.List("snippet,statistics,brandingSettings");
request.Id = id; request.Id = id;
if (content.Items.Count == 4) if (content.Items.Count == 4)
@@ -133,8 +136,6 @@ namespace FoxTube.Pages
if (SecretsVault.IsAuthorized) if (SecretsVault.IsAuthorized)
{ {
SecretsVault.Subscriptions.ForEach(x => Debug.WriteLine($"{x.Snippet.Title}: {x.Snippet.ResourceId.ChannelId}"));
Debug.WriteLine($"Current channel ID: {item.Id}");
bool b = false; bool b = false;
foreach (Subscription s in SecretsVault.Subscriptions) foreach (Subscription s in SecretsVault.Subscriptions)
{ {
@@ -148,7 +149,6 @@ namespace FoxTube.Pages
break; break;
} }
} }
Debug.WriteLine($"Channel was found: {b}");
subscriptionPane.Visibility = Visibility.Visible; subscriptionPane.Visibility = Visibility.Visible;
} }
+20 -4
View File
@@ -502,7 +502,7 @@ namespace FoxTube
s = Sender.None; s = Sender.None;
} }
private void content_Navigated(object sender, NavigationEventArgs e) public void content_Navigated(object sender, NavigationEventArgs e)
{ {
Dictionary<Type, Action> switchCase = new Dictionary<Type, Action>() Dictionary<Type, Action> switchCase = new Dictionary<Type, Action>()
{ {
@@ -535,9 +535,16 @@ namespace FoxTube
} }, } },
{ typeof(ChannelPage), () => { typeof(ChannelPage), () =>
{ {
if(sender.GetType() != typeof(ChannelPage))
{
Methods.NeedToResponse = true;
s = Sender.None;
return;
}
Methods.NeedToResponse = false;
if(SecretsVault.IsAuthorized) if(SecretsVault.IsAuthorized)
{ {
if((content.Content as ChannelPage).channelId == SecretsVault.AccountId) if((content.Content as ChannelPage).channelId == SecretsVault.UserChannel.Id)
{ {
if(nav.SelectedItem != toChannel) if(nav.SelectedItem != toChannel)
nav.SelectedItem = toChannel; nav.SelectedItem = toChannel;
@@ -559,14 +566,23 @@ namespace FoxTube
} }
if(!found) if(!found)
{
nav.SelectedItem = null; nav.SelectedItem = null;
} }
} }
}
else else
nav.SelectedItem = null; nav.SelectedItem = null;
} }, } },
{ typeof(PlaylistPage), () => { typeof(PlaylistPage), () =>
{ {
if(sender.GetType() != typeof(PlaylistPage))
{
Methods.NeedToResponse = true;
s = Sender.None;
return;
}
Methods.NeedToResponse = false;
if((content.Content as PlaylistPage).playlistId == SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.Likes) if((content.Content as PlaylistPage).playlistId == SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.Likes)
{ {
if(nav.SelectedItem != toLiked) if(nav.SelectedItem != toLiked)
@@ -617,7 +633,7 @@ namespace FoxTube
} } } }
}; };
try { navCase[e.SourcePageType](); } try { navCase[content.SourcePageType](); }
catch catch
{ {
nav.SelectedItem = null; nav.SelectedItem = null;
@@ -631,7 +647,7 @@ namespace FoxTube
else else
nav.IsBackEnabled = false; nav.IsBackEnabled = false;
if (e.SourcePageType == typeof(Home) || e.SourcePageType == typeof(Settings) || e.SourcePageType == typeof(Subscriptions)) if (content.SourcePageType == typeof(Home) || content.SourcePageType == typeof(Settings) || content.SourcePageType == typeof(Subscriptions))
{ {
nav.ExpandedModeThresholdWidth = 1008; nav.ExpandedModeThresholdWidth = 1008;
if (nav.DisplayMode == NavigationViewDisplayMode.Expanded) if (nav.DisplayMode == NavigationViewDisplayMode.Expanded)
+3
View File
@@ -62,6 +62,9 @@ namespace FoxTube.Pages
try try
{ {
playlistId = id; playlistId = id;
if (Methods.NeedToResponse)
Methods.MainPage.content_Navigated(this, null);
PlaylistsResource.ListRequest request = SecretsVault.Service.Playlists.List("snippet,contentDetails"); PlaylistsResource.ListRequest request = SecretsVault.Service.Playlists.List("snippet,contentDetails");
request.Id = id; request.Id = id;