Exemple #1
0
        public async void NextSearchResult(object sender)
        {
            if (Searching)
            {
                return;
            }

            try
            {
                Searching = true;
                var client = DI.Resolve <TwitterClient>();

                var maxid = TweetList?.Min(tweet => tweet.Id) - 1;

                var tweets = await client.Search(SearchWord, maxid);

                var contents = tweets.Select(tweet => new TweetControlViewModel(tweet));

                foreach (var content in contents)
                {
                    content.SetProfileAndMediaSource();
                    Dispatch <TweetControlViewModel>(TweetList.Add)(content);
                }
            }
            finally
            {
                Searching = false;
            }
        }
Exemple #2
0
        private async void FetchNextHomeTimeLine(object obj)
        {
            if (!NextHomeTimelineCommand.CanExecute(obj))
            {
                return;
            }

            try
            {
                IsGettingTimeline = true;

                await PopupService.Flash(Application.Current.MainWindow, "タイムライン取得中");

                var maxid  = TweetList.Min(tweet => tweet.Id) - 1;
                var tweets = (await Client.FetchHomeTimeline(maxid: maxid)).Select(tweet => new TweetControlViewModel(tweet));

                foreach (var content in tweets)
                {
                    content.SetProfileAndMediaSource();
                    Dispatch <TweetControlViewModel>(TweetList.Add)(content);
                }
            }
            catch (AggregateException err)
            {
                foreach (var ie in err.InnerExceptions)
                {
                    throw ie;
                }
            }
            catch (CoreTweet.TwitterException err)
            {
                Debug.WriteLine(err);
                MessageBox.Show("Twitter API 取得制限に達しました。\r\n15分間の利用が制限されています。");
            }
            finally
            {
                IsGettingTimeline = false;
                await PopupService.Flash(Application.Current.MainWindow, "タイムライン取得完了");
            }
        }