From d9304fa41787cfde9f92749de0fd1b35eb1d4381 Mon Sep 17 00:00:00 2001 From: Kimura Youichi Date: Tue, 17 May 2016 21:27:59 +0900 Subject: [PATCH] =?utf8?q?Twitter.GetTimelineApi=E3=83=A1=E3=82=BD?= =?utf8?q?=E3=83=83=E3=83=89=E3=82=92GetHomeTimelineApi,=20GetMentionsTime?= =?utf8?q?lineApi=E3=81=AB=E5=88=86=E5=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- OpenTween/Models/HomeTabModel.cs | 2 +- OpenTween/Models/MentionsTabModel.cs | 2 +- OpenTween/Twitter.cs | 61 ++++++++++++++++++------------------ 3 files changed, 32 insertions(+), 33 deletions(-) diff --git a/OpenTween/Models/HomeTabModel.cs b/OpenTween/Models/HomeTabModel.cs index 2a8af335..49691249 100644 --- a/OpenTween/Models/HomeTabModel.cs +++ b/OpenTween/Models/HomeTabModel.cs @@ -70,7 +70,7 @@ namespace OpenTween.Models progress.Report(string.Format(Properties.Resources.GetTimelineWorker_RunWorkerCompletedText5, backward ? -1 : 1)); - await tw.GetTimelineApi(read, MyCommon.WORKERTYPE.Timeline, backward, startup) + await tw.GetHomeTimelineApi(read, this, backward, startup) .ConfigureAwait(false); // 新着時未読クリア diff --git a/OpenTween/Models/MentionsTabModel.cs b/OpenTween/Models/MentionsTabModel.cs index 525a99fa..93bc7aba 100644 --- a/OpenTween/Models/MentionsTabModel.cs +++ b/OpenTween/Models/MentionsTabModel.cs @@ -56,7 +56,7 @@ namespace OpenTween.Models progress.Report(string.Format(Properties.Resources.GetTimelineWorker_RunWorkerCompletedText4, backward ? -1 : 1)); - await tw.GetTimelineApi(read, MyCommon.WORKERTYPE.Reply, backward, startup) + await tw.GetMentionsTimelineApi(read, this, backward, startup) .ConfigureAwait(false); TabInformations.GetInstance().DistributePosts(); diff --git a/OpenTween/Twitter.cs b/OpenTween/Twitter.cs index 5d3ecdf1..104e9b80 100644 --- a/OpenTween/Twitter.cs +++ b/OpenTween/Twitter.cs @@ -162,8 +162,6 @@ namespace OpenTween private List _hashList = new List(); //max_idで古い発言を取得するために保持(lists分は個別タブで管理) - private long minHomeTimeline = long.MaxValue; - private long minMentions = long.MaxValue; private long minDirectmessage = long.MaxValue; private long minDirectmessageSent = long.MaxValue; @@ -778,49 +776,50 @@ namespace OpenTween return Math.Min(count, GetMaxApiResultCount(type)); } - public async Task GetTimelineApi(bool read, MyCommon.WORKERTYPE gType, bool more, bool startup) + public async Task GetHomeTimelineApi(bool read, HomeTabModel tab, bool more, bool startup) { this.CheckAccountState(); - var count = GetApiResultCount(gType, more, startup); + var count = GetApiResultCount(MyCommon.WORKERTYPE.Timeline, more, startup); TwitterStatus[] statuses; - if (gType == MyCommon.WORKERTYPE.Timeline) + if (more) { - if (more) - { - statuses = await this.Api.StatusesHomeTimeline(count, maxId: this.minHomeTimeline) - .ConfigureAwait(false); - } - else - { - statuses = await this.Api.StatusesHomeTimeline(count) - .ConfigureAwait(false); - } + statuses = await this.Api.StatusesHomeTimeline(count, maxId: tab.OldestId) + .ConfigureAwait(false); } else { - if (more) - { - statuses = await this.Api.StatusesMentionsTimeline(count, maxId: this.minMentions) - .ConfigureAwait(false); - } - else - { - statuses = await this.Api.StatusesMentionsTimeline(count) - .ConfigureAwait(false); - } + statuses = await this.Api.StatusesHomeTimeline(count) + .ConfigureAwait(false); } - var minimumId = CreatePostsFromJson(statuses, gType, null, read); - + var minimumId = this.CreatePostsFromJson(statuses, MyCommon.WORKERTYPE.Timeline, tab, read); if (minimumId != null) + tab.OldestId = minimumId.Value; + } + + public async Task GetMentionsTimelineApi(bool read, MentionsTabModel tab, bool more, bool startup) + { + this.CheckAccountState(); + + var count = GetApiResultCount(MyCommon.WORKERTYPE.Reply, more, startup); + + TwitterStatus[] statuses; + if (more) { - if (gType == MyCommon.WORKERTYPE.Timeline) - this.minHomeTimeline = minimumId.Value; - else - this.minMentions = minimumId.Value; + statuses = await this.Api.StatusesMentionsTimeline(count, maxId: tab.OldestId) + .ConfigureAwait(false); } + else + { + statuses = await this.Api.StatusesMentionsTimeline(count) + .ConfigureAwait(false); + } + + var minimumId = this.CreatePostsFromJson(statuses, MyCommon.WORKERTYPE.Reply, tab, read); + if (minimumId != null) + tab.OldestId = minimumId.Value; } public async Task GetUserTimelineApi(bool read, string userName, UserTimelineTabModel tab, bool more) -- 2.11.0