OSDN Git Service

Twitter.GetListsApiメソッドで一度のリクエストで取得するリストの件数を1,000件に変更
authorKimura Youichi <kim.upsilon@bucyou.net>
Mon, 19 Sep 2016 08:11:27 +0000 (17:11 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Mon, 19 Sep 2016 08:50:30 +0000 (17:50 +0900)
OpenTween.Tests/Api/TwitterApiTest.cs
OpenTween/Api/TwitterApi.cs
OpenTween/Resources/ChangeLog.txt
OpenTween/Twitter.cs

index efa1d4c..814a42a 100644 (file)
@@ -324,6 +324,7 @@ namespace OpenTween.Api
                         new Dictionary<string, string> {
                             { "screen_name", "twitterapi" },
                             { "cursor", "-1" },
+                            { "count", "100" },
                         },
                         "/lists/ownerships")
                 )
@@ -331,7 +332,7 @@ namespace OpenTween.Api
 
                 twitterApi.apiConnection = mock.Object;
 
-                await twitterApi.ListsOwnerships("twitterapi", cursor: -1L)
+                await twitterApi.ListsOwnerships("twitterapi", cursor: -1L, count: 100)
                     .ConfigureAwait(false);
 
                 mock.VerifyAll();
@@ -350,6 +351,7 @@ namespace OpenTween.Api
                         new Dictionary<string, string> {
                             { "screen_name", "twitterapi" },
                             { "cursor", "-1" },
+                            { "count", "100" },
                         },
                         "/lists/subscriptions")
                 )
@@ -357,7 +359,7 @@ namespace OpenTween.Api
 
                 twitterApi.apiConnection = mock.Object;
 
-                await twitterApi.ListsSubscriptions("twitterapi", cursor: -1L)
+                await twitterApi.ListsSubscriptions("twitterapi", cursor: -1L, count: 100)
                     .ConfigureAwait(false);
 
                 mock.VerifyAll();
index 8d67f7e..5c80ea1 100644 (file)
@@ -187,7 +187,7 @@ namespace OpenTween.Api
             return this.apiConnection.GetAsync<TwitterSearchResult>(endpoint, param, "/search/tweets");
         }
 
-        public Task<TwitterLists> ListsOwnerships(string screenName, long? cursor = null)
+        public Task<TwitterLists> ListsOwnerships(string screenName, long? cursor = null, int? count = null)
         {
             var endpoint = new Uri("lists/ownerships.json", UriKind.Relative);
             var param = new Dictionary<string, string>
@@ -197,11 +197,13 @@ namespace OpenTween.Api
 
             if (cursor != null)
                 param["cursor"] = cursor.ToString();
+            if (count != null)
+                param["count"] = count.ToString();
 
             return this.apiConnection.GetAsync<TwitterLists>(endpoint, param, "/lists/ownerships");
         }
 
-        public Task<TwitterLists> ListsSubscriptions(string screenName, long? cursor = null)
+        public Task<TwitterLists> ListsSubscriptions(string screenName, long? cursor = null, int? count = null)
         {
             var endpoint = new Uri("lists/subscriptions.json", UriKind.Relative);
             var param = new Dictionary<string, string>
@@ -211,6 +213,8 @@ namespace OpenTween.Api
 
             if (cursor != null)
                 param["cursor"] = cursor.ToString();
+            if (count != null)
+                param["count"] = count.ToString();
 
             return this.apiConnection.GetAsync<TwitterLists>(endpoint, param, "/lists/subscriptions");
         }
index fa43b78..45cfcc4 100644 (file)
@@ -1,6 +1,7 @@
 更新履歴
 
 ==== Ver 1.3.5-dev(2016/xx/xx)
+ * CHG: リストの一覧を表示する際に20件を越える場合のAPIリクエスト回数が少なくなりました
  * FIX: UserStreamsが正常に動作しないことがある不具合を修正
  * FIX: 「このユーザーへの@発言を検索」がv1.3.3から機能しなくなっていた不具合を修正
  * FIX: プロフィール画像のキャッシュ参照時にエラーが発生する不具合を修正
index 2492a36..28aa505 100644 (file)
@@ -1398,11 +1398,13 @@ namespace OpenTween
         {
             this.CheckAccountState();
 
-            var ownedLists = await TwitterLists.GetAllItemsAsync(x => this.Api.ListsOwnerships(this.Username, cursor: x))
-                .ConfigureAwait(false);
+            var ownedLists = await TwitterLists.GetAllItemsAsync(x =>
+                this.Api.ListsOwnerships(this.Username, cursor: x, count: 1000))
+                    .ConfigureAwait(false);
 
-            var subscribedLists = await TwitterLists.GetAllItemsAsync(x => this.Api.ListsSubscriptions(this.Username, cursor: x))
-                .ConfigureAwait(false);
+            var subscribedLists = await TwitterLists.GetAllItemsAsync(x =>
+                this.Api.ListsSubscriptions(this.Username, cursor: x, count: 1000))
+                    .ConfigureAwait(false);
 
             TabInformations.GetInstance().SubscribableLists = Enumerable.Concat(ownedLists, subscribedLists)
                 .Select(x => new ListElement(x, this))