From 91c593311960adea212667bd137228a52019e636 Mon Sep 17 00:00:00 2001 From: Kimura Youichi Date: Sun, 23 Jun 2019 15:31:17 +0900 Subject: [PATCH] =?utf8?q?TabInformations.MuteTab=E3=83=97=E3=83=AD?= =?utf8?q?=E3=83=91=E3=83=86=E3=82=A3=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97T?= =?utf8?q?abs=E3=81=8B=E3=82=89=E3=83=9F=E3=83=A5=E3=83=BC=E3=83=88?= =?utf8?q?=E3=82=BF=E3=83=96=E3=82=92=E9=99=A4=E5=A4=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- OpenTween/FilterDialog.cs | 16 +--------------- OpenTween/Models/TabInformations.cs | 16 ++++++++++++---- OpenTween/Tween.cs | 8 ++------ 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/OpenTween/FilterDialog.cs b/OpenTween/FilterDialog.cs index 09fc4972..c6b92d96 100644 --- a/OpenTween/FilterDialog.cs +++ b/OpenTween/FilterDialog.cs @@ -102,21 +102,7 @@ namespace OpenTween private void RefreshListTabs() { - var tabs = new List(); - - 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)) { diff --git a/OpenTween/Models/TabInformations.cs b/OpenTween/Models/TabInformations.cs index a166c68f..0ef37d9f 100644 --- a/OpenTween/Models/TabInformations.cs +++ b/OpenTween/Models/TabInformations.cs @@ -41,6 +41,8 @@ namespace OpenTween.Models { //個別タブの情報をDictionaryで保持 public TabCollection Tabs { get; } = new TabCollection(); + public MuteTabModel MuteTab { get; private set; } + public ConcurrentDictionary Posts { get; } = new ConcurrentDictionary(); private Dictionary _quotes = new Dictionary(); @@ -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(); + 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().ToArray()) { - if (tab.TabType == MyCommon.TabUsageType.Mute) - continue; - // フィルタに変更のあったタブのみを対象とする if (!tab.FilterModified) continue; diff --git a/OpenTween/Tween.cs b/OpenTween/Tween.cs index 8b446888..860a2af8 100644 --- a/OpenTween/Tween.cs +++ b/OpenTween/Tween.cs @@ -1057,15 +1057,11 @@ namespace OpenTween if (this._statuses.GetTabByType() == null) this._statuses.AddTab(new FavoritesTabModel()); - if (this._statuses.GetTabByType() == 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() .Select(x => this._statuses.Tabs[x.Text]) - .Append(this._statuses.GetTabByType(MyCommon.TabUsageType.Mute)); + .Append(this._statuses.MuteTab); foreach (var tab in tabs) { -- 2.11.0