OSDN Git Service

ITwitterCredentialとアクセス手段ごとの具象クラスを追加
[opentween/open-tween.git] / OpenTween / Twitter.cs
index b9a7d3a..48be5ba 100644 (file)
@@ -228,15 +228,14 @@ namespace OpenTween
             this.Api.Initialize(token, tokenSecret, userId, username);
         }
 
-        public void Initialize(TwitterAppToken appToken, string token, string tokenSecret, string username, long userId)
+        public void Initialize(ITwitterCredential credential, string username, long userId)
         {
             // OAuth認証
-            if (MyCommon.IsNullOrEmpty(token) || MyCommon.IsNullOrEmpty(tokenSecret) || MyCommon.IsNullOrEmpty(username))
-            {
+            if (credential is TwitterCredentialNone)
                 Twitter.AccountState = MyCommon.ACCOUNT_STATE.Invalid;
-            }
+
             this.ResetApiStatus();
-            this.Api.Initialize(appToken, token, tokenSecret, userId, username);
+            this.Api.Initialize(credential, userId, username);
         }
 
         public async Task<PostClass?> PostStatus(PostStatusParams param)
@@ -682,7 +681,7 @@ namespace OpenTween
                 var request = new UserTweetsAndRepliesRequest(userId)
                 {
                     Count = count,
-                    Cursor = more ? tab.CursorBottom : null,
+                    Cursor = more ? tab.CursorBottom : tab.CursorTop,
                 };
                 var response = await request.Send(this.Api.Connection)
                     .ConfigureAwait(false);
@@ -694,6 +693,9 @@ namespace OpenTween
                     .ToArray();
 
                 tab.CursorBottom = response.CursorBottom;
+
+                if (!more)
+                    tab.CursorTop = response.CursorTop;
             }
             else
             {
@@ -881,7 +883,7 @@ namespace OpenTween
                 var request = new ListLatestTweetsTimelineRequest(tab.ListInfo.Id.ToString())
                 {
                     Count = count,
-                    Cursor = more ? tab.CursorBottom : null,
+                    Cursor = more ? tab.CursorBottom : tab.CursorTop,
                 };
                 var response = await request.Send(this.Api.Connection)
                     .ConfigureAwait(false);
@@ -895,6 +897,9 @@ namespace OpenTween
 
                 statuses = convertedStatuses.ToArray();
                 tab.CursorBottom = response.CursorBottom;
+
+                if (!more)
+                    tab.CursorTop = response.CursorTop;
             }
             else if (more)
             {
@@ -1088,7 +1093,7 @@ namespace OpenTween
                 var request = new SearchTimelineRequest(tab.SearchWords)
                 {
                     Count = count,
-                    Cursor = more ? tab.CursorBottom : null,
+                    Cursor = more ? tab.CursorBottom : tab.CursorTop,
                 };
                 var response = await request.Send(this.Api.Connection)
                     .ConfigureAwait(false);
@@ -1099,6 +1104,9 @@ namespace OpenTween
                     .ToArray();
 
                 tab.CursorBottom = response.CursorBottom;
+
+                if (!more)
+                    tab.CursorTop = response.CursorTop;
             }
             else
             {
@@ -1428,12 +1436,6 @@ namespace OpenTween
         public string[] GetHashList()
             => this.postFactory.GetReceivedHashtags();
 
-        public string AccessToken
-            => ((TwitterApiConnection)this.Api.Connection).AccessToken;
-
-        public string AccessTokenSecret
-            => ((TwitterApiConnection)this.Api.Connection).AccessSecret;
-
         private void CheckAccountState()
         {
             if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid)