OSDN Git Service

TabInformations.MuteTabプロパティを追加しTabsからミュートタブを除外
authorKimura Youichi <kim.upsilon@bucyou.net>
Sun, 23 Jun 2019 06:31:17 +0000 (15:31 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sun, 23 Jun 2019 07:03:57 +0000 (16:03 +0900)
OpenTween/FilterDialog.cs
OpenTween/Models/TabInformations.cs
OpenTween/Tween.cs

index 09fc497..c6b92d9 100644 (file)
@@ -102,21 +102,7 @@ namespace OpenTween
 
         private void RefreshListTabs()
         {
-            var tabs = new List<TabModel>();
-
-            foreach (var tab in this._sts.Tabs)
-            {
-                if (tab.TabType == MyCommon.TabUsageType.Mute)
-                    continue;
-
-                tabs.Add(tab);
-            }
-
-            var muteTab = this._sts.GetTabByType(MyCommon.TabUsageType.Mute);
-            if (muteTab != null)
-                tabs.Add(muteTab);
-
-            this.tabs = tabs;
+            this.tabs = this._sts.Tabs.Append(this._sts.MuteTab).ToList();
 
             using (ControlTransaction.Update(this.ListTabs))
             {
index a166c68..0ef37d9 100644 (file)
@@ -41,6 +41,8 @@ namespace OpenTween.Models
     {
         //個別タブの情報をDictionaryで保持
         public TabCollection Tabs { get; } = new TabCollection();
+        public MuteTabModel MuteTab { get; private set; }
+
         public ConcurrentDictionary<long, PostClass> Posts { get; } = new ConcurrentDictionary<long, PostClass>();
 
         private Dictionary<long, PostClass> _quotes = new Dictionary<long, PostClass>();
@@ -113,6 +115,15 @@ namespace OpenTween.Models
         {
             lock (this.LockObj)
             {
+                if (tab is MuteTabModel muteTab)
+                {
+                    if (this.MuteTab != null)
+                        return false;
+
+                    this.MuteTab = muteTab;
+                    return true;
+                }
+
                 if (this.Tabs.Contains(tab.TabName))
                     return false;
 
@@ -548,7 +559,7 @@ namespace OpenTween.Models
 
         public bool IsMuted(PostClass post, bool isHomeTimeline)
         {
-            var muteTab = this.GetTabByType<MuteTabModel>();
+            var muteTab = this.MuteTab;
             if (muteTab != null && muteTab.AddFiltered(post) == MyCommon.HITRESULT.Move)
                 return true;
 
@@ -686,9 +697,6 @@ namespace OpenTween.Models
 
                 foreach (var tab in this.Tabs.OfType<FilterTabModel>().ToArray())
                 {
-                    if (tab.TabType == MyCommon.TabUsageType.Mute)
-                        continue;
-
                     // フィルタに変更のあったタブのみを対象とする
                     if (!tab.FilterModified)
                         continue;
index 8b44688..860a2af 100644 (file)
@@ -1057,15 +1057,11 @@ namespace OpenTween
             if (this._statuses.GetTabByType<FavoritesTabModel>() == null)
                 this._statuses.AddTab(new FavoritesTabModel());
 
-            if (this._statuses.GetTabByType<MuteTabModel>() == null)
+            if (this._statuses.MuteTab == null)
                 this._statuses.AddTab(new MuteTabModel());
 
             foreach (var tab in _statuses.Tabs)
             {
-                // ミュートタブは表示しない
-                if (tab.TabType == MyCommon.TabUsageType.Mute)
-                    continue;
-
                 if (!AddNewTab(tab, startup: true))
                     throw new TabException(Properties.Resources.TweenMain_LoadText1);
             }
@@ -7197,7 +7193,7 @@ namespace OpenTween
 
             var tabs = this.ListTab.TabPages.Cast<TabPage>()
                 .Select(x => this._statuses.Tabs[x.Text])
-                .Append(this._statuses.GetTabByType(MyCommon.TabUsageType.Mute));
+                .Append(this._statuses.MuteTab);
 
             foreach (var tab in tabs)
             {