1 // OpenTween - Client of Twitter
2 // Copyright (c) 2007-2011 kiri_feather (@kiri_feather) <kiri.feather@gmail.com>
3 // (c) 2008-2011 Moz (@syo68k)
4 // (c) 2008-2011 takeshik (@takeshik) <http://www.takeshik.org/>
5 // (c) 2010-2011 anis774 (@anis774) <http://d.hatena.ne.jp/anis774/>
6 // (c) 2010-2011 fantasticswallow (@f_swallow) <http://twitter.com/f_swallow>
7 // (c) 2011 Egtra (@egtra) <http://dev.activebasic.com/egtra/>
8 // (c) 2012 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
9 // All rights reserved.
11 // This file is part of OpenTween.
13 // This program is free software; you can redistribute it and/or modify it
14 // under the terms of the GNU General Public License as published by the Free
15 // Software Foundation; either version 3 of the License, or (at your option)
18 // This program is distributed in the hope that it will be useful, but
19 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 // You should have received a copy of the GNU General Public License along
24 // with this program. If not, see <http://www.gnu.org/licenses/>, or write to
25 // the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
26 // Boston, MA 02110-1301, USA.
31 using System.Collections.Concurrent;
32 using System.Collections.Generic;
35 using System.Threading.Tasks;
37 namespace OpenTween.Models
39 public abstract class InternalStorageTabModel : TabModel
41 protected readonly ConcurrentDictionary<PostId, PostClass> internalPosts = new();
43 public override ConcurrentDictionary<PostId, PostClass> Posts
44 => this.internalPosts;
46 protected InternalStorageTabModel(string tabName)
51 public override void AddPostQueue(PostClass post)
53 if (TabInformations.GetInstance().IsGlobalMuted(post))
56 this.internalPosts.TryAdd(post.StatusId, post);
58 base.AddPostQueue(post);
61 public override void EnqueueRemovePost(PostId statusId, bool setIsDeleted)
63 base.EnqueueRemovePost(statusId, setIsDeleted);
67 if (this.internalPosts.TryGetValue(statusId, out var post))
68 post.IsDeleted = true;
72 public override bool RemovePostImmediately(PostId statusId)
74 if (!base.RemovePostImmediately(statusId))
77 this.internalPosts.TryRemove(statusId, out _);
82 public override void ClearIDs()
85 this.internalPosts.Clear();
88 internal override bool SetReadState(PostId statusId, bool read)
90 if (this.Posts.TryGetValue(statusId, out var post))
93 return base.SetReadState(statusId, read);