public async Task NextThreads(string sortType) { if (IsEndlessLoading) { return; } IsEndlessLoading = true; string dummy; var response = await Reddit.Instance.ListThreads(CurrentSubreddit.Name, sortType, _nextListing, CurrentSubreddit.Threads.Count); var threadListings = response.ParseListings(out _nextListing, out dummy); if (threadListings == null) { return; } IsEndlessLoading = false; foreach (var jthread in threadListings) { CurrentSubreddit.Threads.Add(SubredditThread.Parse(jthread.Value <JObject>("data"))); } }
public async void LoadSubreddit(string subreddit, string sortType) { IsSubredditLoading = true; if (!ConnectionHelper.IsInternetAvailable) { IsNotConnectedToInternet = true; IsSubredditLoading = false; return; } IsNotConnectedToInternet = false; if (!subreddit.StartsWith("/r/")) { subreddit = subreddit.Insert(0, "/r/"); } string dummy; var response = await Reddit.Instance.ListThreads(subreddit, sortType); var threadListings = response.ParseListings(out _nextListing, out dummy); if (threadListings == null) { return; } var newThreads = new ObservableCollection <SubredditThread>(); foreach (var jthread in threadListings) { newThreads.Add(SubredditThread.Parse(jthread.Value <JObject>("data"))); } CurrentSubreddit = new Subreddit(subreddit, newThreads); QueriedSubreddits = Favorites; OnPropertyChanged("InFavorites"); OnPropertyChanged("NotInFavorites"); IsSubredditLoading = false; }