From: Kimura Youichi Date: Sun, 23 Jun 2019 06:31:17 +0000 (+0900) Subject: TabInformations.MuteTabプロパティを追加しTabsからミュートタブを除外 X-Git-Tag: OpenTween_v2.4.0~24^2~1 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=91c593311960adea212667bd137228a52019e636;p=opentween%2Fopen-tween.git TabInformations.MuteTabプロパティを追加しTabsからミュートタブを除外 --- 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) {