OSDN Git Service

PostClass.ReplyToListの型をTuple<long, string>に変更
authorKimura Youichi <kim.upsilon@bucyou.net>
Sat, 24 Sep 2016 06:07:47 +0000 (15:07 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 11 Nov 2017 21:06:15 +0000 (06:06 +0900)
ツイートに含まれるメンションのユーザーIDを取得できるようにするための変更

OpenTween.Tests/Models/PostClassTest.cs
OpenTween/Models/PostClass.cs
OpenTween/Tween.cs
OpenTween/TweetDetailsView.cs
OpenTween/Twitter.cs

index ac8dd41..169009a 100644 (file)
@@ -191,7 +191,7 @@ namespace OpenTween.Models
                 InReplyToUser = "hogehoge",
                 InReplyToUserId = 100L,
                 IsReply = true,
-                ReplyToList = new List<string> {"hogehoge"},
+                ReplyToList = new List<Tuple<long, string>> { Tuple.Create(100L, "hogehoge") },
             };
 
             post.IsDeleted = true;
index 1cf0558..a7c398f 100644 (file)
@@ -102,7 +102,7 @@ namespace OpenTween.Models
         private long? _InReplyToStatusId;
         public string Source { get; set; }
         public Uri SourceUri { get; set; }
-        public List<string> ReplyToList { get; set; }
+        public List<Tuple<long, string>> ReplyToList { get; set; }
         public bool IsMe { get; set; }
         public bool IsDm { get; set; }
         public long UserId { get; set; }
@@ -191,7 +191,7 @@ namespace OpenTween.Models
         {
             RetweetedBy = "";
             Media = new List<MediaInfo>();
-            ReplyToList = new List<string>();
+            ReplyToList = new List<Tuple<long, string>>();
             QuoteStatusIds = new long[0];
             ExpandedUrls = new ExpandedUrlInfo[0];
         }
@@ -305,7 +305,7 @@ namespace OpenTween.Models
                     this.InReplyToUser = "";
                     this.InReplyToUserId = null;
                     this.IsReply = false;
-                    this.ReplyToList = new List<string>();
+                    this.ReplyToList = new List<Tuple<long, string>>();
                     this._states = States.None;
                 }
                 _IsDeleted = value;
@@ -461,7 +461,7 @@ namespace OpenTween.Models
         public PostClass Clone()
         {
             var clone = (PostClass)this.MemberwiseClone();
-            clone.ReplyToList = new List<string>(this.ReplyToList);
+            clone.ReplyToList = new List<Tuple<long, string>>(this.ReplyToList);
             clone.Media = new List<MediaInfo>(this.Media);
             clone.QuoteStatusIds = this.QuoteStatusIds.ToArray();
             clone.ExpandedUrls = this.ExpandedUrls.Select(x => x.Clone()).ToArray();
index 86d911f..65e8203 100644 (file)
@@ -2055,10 +2055,10 @@ namespace OpenTween
             else if (TargetPost.IsReply)
                 //自分宛返信
                 cl = _clAtSelf;
-            else if (BasePost.ReplyToList.Contains(TargetPost.ScreenName.ToLowerInvariant()))
+            else if (BasePost.ReplyToList.Any(x => x.Item1 == TargetPost.UserId))
                 //返信先
                 cl = _clAtFromTarget;
-            else if (TargetPost.ReplyToList.Contains(BasePost.ScreenName.ToLowerInvariant()))
+            else if (TargetPost.ReplyToList.Any(x => x.Item1 == BasePost.UserId))
                 //その人への返信
                 cl = _clAtTarget;
             else if (TargetPost.ScreenName.Equals(BasePost.ScreenName, StringComparison.OrdinalIgnoreCase))
@@ -6714,10 +6714,10 @@ namespace OpenTween
                     post.RetweetedBy == _anchorPost.ScreenName ||
                     post.ScreenName == _anchorPost.RetweetedBy ||
                     (!string.IsNullOrEmpty(post.RetweetedBy) && post.RetweetedBy == _anchorPost.RetweetedBy) ||
-                    _anchorPost.ReplyToList.Contains(post.ScreenName.ToLowerInvariant()) ||
-                    _anchorPost.ReplyToList.Contains(post.RetweetedBy.ToLowerInvariant()) ||
-                    post.ReplyToList.Contains(_anchorPost.ScreenName.ToLowerInvariant()) ||
-                    post.ReplyToList.Contains(_anchorPost.RetweetedBy.ToLowerInvariant()))
+                    _anchorPost.ReplyToList.Any(x => x.Item1 == post.UserId) ||
+                    _anchorPost.ReplyToList.Any(x => x.Item1 == post.RetweetedByUserId) ||
+                    post.ReplyToList.Any(x => x.Item1 == _anchorPost.UserId) ||
+                    post.ReplyToList.Any(x => x.Item1 == _anchorPost.RetweetedByUserId))
                 {
                     SelectListItem(_curList, idx);
                     _curList.EnsureVisible(idx);
@@ -7758,7 +7758,7 @@ namespace OpenTween
                                 }
                                 if (isAll)
                                 {
-                                    foreach (string nm in post.ReplyToList)
+                                    foreach (string nm in post.ReplyToList.Select(x => x.Item2))
                                     {
                                         if (!ids.Contains("@" + nm + " ") &&
                                             !nm.Equals(tw.Username, StringComparison.CurrentCultureIgnoreCase))
@@ -7814,7 +7814,7 @@ namespace OpenTween
                             {
                                 ids += "@" + post.ScreenName + " ";
                             }
-                            foreach (string nm in post.ReplyToList)
+                            foreach (string nm in post.ReplyToList.Select(x => x.Item2))
                             {
                                 if (!ids.Contains("@" + nm + " ") &&
                                     !nm.Equals(tw.Username, StringComparison.CurrentCultureIgnoreCase))
index 9909d82..21c46d4 100644 (file)
@@ -148,7 +148,7 @@ namespace OpenTween
                 sb.AppendFormat("IsRead         : {0}<br>", post.IsRead);
                 sb.AppendFormat("IsReply        : {0}<br>", post.IsReply);
 
-                foreach (string nm in post.ReplyToList)
+                foreach (string nm in post.ReplyToList.Select(x => x.Item2))
                 {
                     sb.AppendFormat("ReplyToList    : {0}<br>", nm);
                 }
index 5216259..3a13de2 100644 (file)
@@ -844,7 +844,7 @@ namespace OpenTween
             post.Source = string.Intern(sourceText);
             post.SourceUri = sourceUri;
 
-            post.IsReply = post.RetweetedId == null && post.ReplyToList.Contains(_uname);
+            post.IsReply = post.RetweetedId == null && post.ReplyToList.Any(x => x.Item1 == this.UserId);
             post.IsExcludeReply = false;
 
             if (post.IsMe)
@@ -1536,7 +1536,7 @@ namespace OpenTween
             }
         }
 
-        public string CreateHtmlAnchor(string text, List<string> AtList, TwitterEntities entities, List<MediaInfo> media)
+        public string CreateHtmlAnchor(string text, List<Tuple<long, string>> AtList, TwitterEntities entities, List<MediaInfo> media)
         {
             if (entities != null)
             {
@@ -1551,9 +1551,7 @@ namespace OpenTween
                 {
                     foreach (var ent in entities.UserMentions)
                     {
-                        var screenName = ent.ScreenName.ToLowerInvariant();
-                        if (!AtList.Contains(screenName))
-                            AtList.Add(screenName);
+                        AtList.Add(Tuple.Create(ent.Id, ent.ScreenName));
                     }
                 }
                 if (entities.Media != null)