OSDN Git Service

C# 8.0 のnull許容参照型を有効化
[opentween/open-tween.git] / OpenTween / Models / InternalStorageTabModel.cs
index 298bcc8..0e39cd5 100644 (file)
@@ -25,6 +25,8 @@
 // the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
 // Boston, MA 02110-1301, USA.
 
+#nullable enable
+
 using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
@@ -50,10 +52,9 @@ namespace OpenTween.Models
             if (TabInformations.GetInstance().IsMuted(post, isHomeTimeline: false))
                 return;
 
-            base.AddPostQueue(post);
+            this.internalPosts.TryAdd(post.StatusId, post);
 
-            if (!this.internalPosts.TryAdd(post.StatusId, post))
-                return;
+            base.AddPostQueue(post);
         }
 
         public override void EnqueueRemovePost(long statusId, bool setIsDeleted)
@@ -62,8 +63,7 @@ namespace OpenTween.Models
 
             if (setIsDeleted)
             {
-                PostClass post;
-                if (this.internalPosts.TryGetValue(statusId, out post))
+                if (this.internalPosts.TryGetValue(statusId, out var post))
                     post.IsDeleted = true;
             }
         }
@@ -73,8 +73,7 @@ namespace OpenTween.Models
             if (!base.RemovePostImmediately(statusId))
                 return false;
 
-            PostClass removedPost;
-            this.internalPosts.TryRemove(statusId, out removedPost);
+            this.internalPosts.TryRemove(statusId, out _);
 
             return true;
         }
@@ -84,5 +83,13 @@ namespace OpenTween.Models
             base.ClearIDs();
             this.internalPosts.Clear();
         }
+
+        internal override bool SetReadState(long statusId, bool read)
+        {
+            if (this.Posts.TryGetValue(statusId, out var post))
+                post.IsRead = read;
+
+            return base.SetReadState(statusId, read);
+        }
     }
 }