/// <summary> /// If this page is navigated to from elsewhere, parse the parameters to maintain state and retrieve links /// </summary> /// <param name="e">Navigation parameters of type: ListingDisplayParameters</param> protected async override void OnNavigatedTo(NavigationEventArgs e) { current_state = (State)(e.Parameter); requester = await RedditRequester.MakeRedditRequester(current_state); current_state = await requester.RefreshToken(); if (current_state.logged_in) { login_but.Visibility = Visibility.Collapsed; logout_but.Visibility = Visibility.Visible; subreddit_but.Visibility = Visibility.Visible; } else { login_but.Visibility = Visibility.Visible; logout_but.Visibility = Visibility.Collapsed; subreddit_but.Visibility = Visibility.Collapsed; } current_subreddit_label.Text = (current_state.current_subreddit.title == null || current_state.current_subreddit.title.Equals("")) ? "Front Page" : current_state.current_subreddit.title; need_to_scroll = true; if (current_state.current_subreddit.title == null || current_state.current_subreddit.title.Equals("")) { await GetHot(""); front_page_but.Visibility = Visibility.Collapsed; } else { await GetHot(current_state.current_subreddit); } }
protected async override void OnNavigatedTo(NavigationEventArgs e) { current_state = (State)(e.Parameter); requester = await RedditRequester.MakeRedditRequester(current_state); subreddit_buttons = new List <SubredditButton>(); current_state = await requester.RefreshToken(); await GetSubreddits(); progress_ring.Visibility = Visibility.Collapsed; progress_ring.IsActive = false; }
/// <summary> /// Logs the current user out by refreshing the current state /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void logout_but_Click(object sender, RoutedEventArgs e) { State blank_state = new State(); blank_state.access_token = ""; blank_state.current_link = new Link(); blank_state.current_subreddit = new Subreddit(); blank_state.refresh_token = ""; blank_state.expire_time = DateTime.Now; blank_state.logged_in = false; max_count = 0; requester = await RedditRequester.MakeRedditRequester(blank_state); this.Frame.Navigate(typeof(LinksDisplay), blank_state); }
/// <summary> /// Unpackages parameters when this page is navigated to /// </summary> /// <param name="e">Must be of type CommentViewParameters</param> protected async override void OnNavigatedTo(NavigationEventArgs e) { current_state = (State)e.Parameter; RedditRequester requester = await RedditRequester.MakeRedditRequester(current_state); current_state = await requester.RefreshToken(); Tuple <List <Comment>, string> result = await requester.GetComments(current_state.current_link, ""); List <Comment> comments = result.Item1; string after = result.Item2; AddCommentsToUI(comments, after); progress_ring.Visibility = Visibility.Collapsed; progress_ring.IsActive = false; }