OSDN Git Service

設定ファイルの読み込み・保存に関するコードをSettingManagerクラスに移動
[opentween/open-tween.git] / OpenTween / Tween.cs
index 996c9e0..f508b6a 100644 (file)
@@ -52,6 +52,7 @@ using OpenTween.Api.DataModel;
 using OpenTween.Connection;
 using OpenTween.Models;
 using OpenTween.OpenTweenCustomControl;
+using OpenTween.Setting;
 using OpenTween.Thumbnail;
 
 namespace OpenTween
@@ -260,10 +261,6 @@ namespace OpenTween
         private PostClass _curPost;
         private bool _isColumnChanged = false;
 
-        // 各タブの発言一覧のスクロール位置・選択状態を保持するフィールド
-        private IDictionary<string, ListViewScroll> listViewScroll = new Dictionary<string, ListViewScroll>();
-        private IDictionary<string, ListViewSelection> listViewSelection = new Dictionary<string, ListViewSelection>();
-
         private const int MAX_WORKER_THREADS = 20;
         private SemaphoreSlim workerSemaphore = new SemaphoreSlim(MAX_WORKER_THREADS);
         private CancellationTokenSource workerCts = new CancellationTokenSource();
@@ -805,6 +802,7 @@ namespace OpenTween
 
             //Twitter用通信クラス初期化
             Networking.DefaultTimeout = TimeSpan.FromSeconds(this._cfgCommon.DefaultTimeOut);
+            Networking.UploadImageTimeout = TimeSpan.FromSeconds(this._cfgCommon.UploadImageTimeout);
             Networking.SetWebProxy(this._cfgLocal.ProxyType,
                 this._cfgLocal.ProxyAddress, this._cfgLocal.ProxyPort,
                 this._cfgLocal.ProxyUser, this._cfgLocal.ProxyPassword);
@@ -847,7 +845,7 @@ namespace OpenTween
             ImageSelector.Initialize(tw, this.tw.Configuration, _cfgCommon.UseImageServiceName, _cfgCommon.UseImageService);
 
             //ハッシュタグ/@id関連
-            AtIdSupl = new AtIdSupplement(SettingAtIdList.Load().AtIdList, "@");
+            AtIdSupl = new AtIdSupplement(SettingManager.AtIdList.AtIdList, "@");
             HashSupl = new AtIdSupplement(_cfgCommon.HashTags, "#");
             HashMgr = new HashtagManage(HashSupl,
                                     _cfgCommon.HashTags.ToArray(),
@@ -1200,31 +1198,17 @@ namespace OpenTween
 
         private void LoadConfig()
         {
-            _cfgCommon = SettingCommon.Load();
-            SettingCommon.Instance = this._cfgCommon;
-            if (_cfgCommon.UserAccounts == null || _cfgCommon.UserAccounts.Count == 0)
-            {
-                _cfgCommon.UserAccounts = new List<UserAccount>();
-                if (!string.IsNullOrEmpty(_cfgCommon.UserName))
-                {
-                    UserAccount account = new UserAccount();
-                    account.Username = _cfgCommon.UserName;
-                    account.UserId = _cfgCommon.UserId;
-                    account.Token = _cfgCommon.Token;
-                    account.TokenSecret = _cfgCommon.TokenSecret;
+            SettingManager.LoadAll();
 
-                    _cfgCommon.UserAccounts.Add(account);
-                }
-            }
-
-            _cfgLocal = SettingLocal.Load();
+            this._cfgCommon = SettingManager.Common;
+            this._cfgLocal = SettingManager.Local;
 
             // v1.2.4 以前の設定には ScaleDimension の項目がないため、現在の DPI と同じとして扱う
             if (_cfgLocal.ScaleDimension.IsEmpty)
                 _cfgLocal.ScaleDimension = this.CurrentAutoScaleDimensions;
 
-            var tabsSetting = SettingTabs.Load().Tabs;
-            foreach (var tabSetting in tabsSetting)
+            var tabSettings = SettingManager.Tabs;
+            foreach (var tabSetting in tabSettings.Tabs)
             {
                 TabModel tab;
                 switch (tabSetting.TabType)
@@ -1412,8 +1396,8 @@ namespace OpenTween
             // 現在表示中のタブのスクロール位置を退避
             var curListScroll = this.SaveListViewScroll(this._curList, curTabModel);
 
-            // 現在表示中のタブのリスト上の選択位置などを退避
-            var curListSelection = this.SaveListViewSelection(this._curList, curTabModel);
+            // タブのリスト上の選択位置などを退避
+            var listSelections = this.SaveListViewSelection();
 
             //更新確定
             PostClass[] notifyPosts;
@@ -1425,6 +1409,37 @@ namespace OpenTween
 
             if (MyCommon._endingFlag) return;
 
+            // リストに反映&選択状態復元
+            foreach (var tabPage in this.ListTab.TabPages.Cast<TabPage>())
+            {
+                var listView = (DetailsListView)tabPage.Tag;
+                var tabModel = this._statuses.Tabs[tabPage.Text];
+
+                if (listView.VirtualListSize != tabModel.AllCount || isDelete)
+                {
+                    using (ControlTransaction.Update(listView))
+                    {
+                        if (listView == this._curList)
+                            this.PurgeListViewItemCache();
+
+                        try
+                        {
+                            // リスト件数更新
+                            listView.VirtualListSize = tabModel.AllCount;
+                        }
+                        catch (NullReferenceException ex)
+                        {
+                            // WinForms 内部で ListView.set_TopItem が発生させている例外
+                            // https://ja.osdn.net/ticket/browse.php?group_id=6526&tid=36588
+                            MyCommon.TraceOut(ex, $"TabType: {tabModel.TabType}, Count: {tabModel.AllCount}, ListSize: {listView.VirtualListSize}");
+                        }
+
+                        // 選択位置などを復元
+                        this.RestoreListViewSelection(listView, tabModel, listSelections[tabModel.TabName]);
+                    }
+                }
+            }
+
             if (addCount > 0)
             {
                 if (this._cfgCommon.TabIconDisp)
@@ -1442,24 +1457,8 @@ namespace OpenTween
                 }
             }
 
-            // リストに反映&選択状態復元
-            if (this._curList.VirtualListSize != curTabModel.AllCount || isDelete)
-            {
-                using (ControlTransaction.Update(this._curList))
-                {
-                    this.PurgeListViewItemCache();
-
-                    // リスト件数更新
-                    this._curList.VirtualListSize = curTabModel.AllCount;
-
-                    // 選択位置などを復元
-                    this.RestoreListViewSelection(this._curList, curTabModel, curListSelection);
-                }
-
-                // スクロール位置の復元は Begin/EndUpdate の外で行う
-                // 参照: https://github.com/opentween/OpenTween/commit/7dbf6491
-                this.RestoreListViewScroll(this._curList, curTabModel, curListScroll);
-            }
+            // スクロール位置を復元
+            this.RestoreListViewScroll(this._curList, curTabModel, curListScroll);
 
             //新着通知
             NotifyNewPosts(notifyPosts, soundFile, addCount, newMentionOrDm);
@@ -1504,9 +1503,9 @@ namespace OpenTween
 
             if (listScroll.ScrollLockMode == ScrollLockMode.FixedToItem)
             {
-                var topItem = listView.TopItem;
-                if (topItem != null)
-                    listScroll.TopItemStatusId = tab.GetStatusIdAt(topItem.Index);
+                var topItemIndex = listView.TopItem?.Index ?? -1;
+                if (topItemIndex != -1 && topItemIndex < tab.AllCount)
+                    listScroll.TopItemStatusId = tab.GetStatusIdAt(topItemIndex);
             }
 
             return listScroll;
@@ -1610,16 +1609,16 @@ namespace OpenTween
 
         private long? GetFocusedStatusId(DetailsListView listView, TabModel tab)
         {
-            var focusedItem = listView.FocusedItem;
+            var index = listView.FocusedItem?.Index ?? -1;
 
-            return focusedItem != null ? tab.GetStatusIdAt(focusedItem.Index) : (long?)null;
+            return index != -1 && index < tab.AllCount ? tab.GetStatusIdAt(index) : (long?)null;
         }
 
         private long? GetSelectionMarkStatusId(DetailsListView listView, TabModel tab)
         {
-            var selectionMarkIndex = listView.SelectionMark;
+            var index = listView.SelectionMark;
 
-            return selectionMarkIndex != -1 ? tab.GetStatusIdAt(selectionMarkIndex) : (long?)null;
+            return index != -1 && index < tab.AllCount ? tab.GetStatusIdAt(index) : (long?)null;
         }
 
         /// <summary>
@@ -3368,7 +3367,7 @@ namespace OpenTween
                 FavorareMenuItem.Enabled = true;
                 ShowRelatedStatusesMenuItem.Enabled = true;  //PublicSearchの時問題出るかも
 
-                if (_curPost.IsProtect)
+                if (!_curPost.CanRetweetBy(this.twitterApi.CurrentUserId))
                 {
                     ReTweetStripMenuItem.Enabled = false;
                     ReTweetUnofficialStripMenuItem.Enabled = false;
@@ -3475,23 +3474,27 @@ namespace OpenTween
                         else
                         {
                             if (post.RetweetedByUserId == this.tw.UserId)
+                            {
                                 // 自分が RT したツイート (自分が RT した自分のツイートも含む)
                                 //   => RT を取り消し
                                 await this.twitterApi.StatusesDestroy(post.StatusId)
                                     .IgnoreResponse();
-
-                            if (post.UserId == this.tw.UserId)
+                            }
+                            else
                             {
-                                if (post.RetweetedId != null)
-                                    // 他人に RT された自分のツイート
-                                    //   => RT 元の自分のツイートを削除
-                                    await this.twitterApi.StatusesDestroy(post.RetweetedId.Value)
-                                        .IgnoreResponse();
-                                else
-                                    // 自分のツイート
-                                    //   => ツイートを削除
-                                    await this.twitterApi.StatusesDestroy(post.StatusId)
-                                        .IgnoreResponse();
+                                if (post.UserId == this.tw.UserId)
+                                {
+                                    if (post.RetweetedId != null)
+                                        // 他人に RT された自分のツイート
+                                        //   => RT 元の自分のツイートを削除
+                                        await this.twitterApi.StatusesDestroy(post.RetweetedId.Value)
+                                            .IgnoreResponse();
+                                    else
+                                        // 自分のツイート
+                                        //   => ツイートを削除
+                                        await this.twitterApi.StatusesDestroy(post.StatusId)
+                                            .IgnoreResponse();
+                                }
                             }
                         }
                     }
@@ -3761,6 +3764,7 @@ namespace OpenTween
                     TwitterApiConnection.RestApiHost = this._cfgCommon.TwitterApiHost;
 
                     Networking.DefaultTimeout = TimeSpan.FromSeconds(this._cfgCommon.DefaultTimeOut);
+                    Networking.UploadImageTimeout = TimeSpan.FromSeconds(this._cfgCommon.UploadImageTimeout);
                     Networking.SetWebProxy(this._cfgLocal.ProxyType,
                         this._cfgLocal.ProxyAddress, this._cfgLocal.ProxyPort,
                         this._cfgLocal.ProxyUser, this._cfgLocal.ProxyPassword);
@@ -4816,9 +4820,11 @@ namespace OpenTween
             //文字数カウント
             var remainCount = this.tw.GetTextLengthRemain(statusText);
 
-            if (this.ImageSelector.Visible && !string.IsNullOrEmpty(this.ImageSelector.ServiceName))
+            var uploadService = this.ImageSelector.SelectedService;
+            if (this.ImageSelector.Visible && uploadService != null)
             {
-                remainCount -= this.tw.Configuration.CharactersReservedPerMedia;
+                // TODO: ImageSelector で選択中の画像の枚数が mediaCount 引数に渡るようにする
+                remainCount -= uploadService.GetReservedTextLength(1);
             }
 
             return remainCount;
@@ -5102,7 +5108,7 @@ namespace OpenTween
                         using (Font fnt = new Font(e.Item.Font, FontStyle.Bold))
                         {
                             TextRenderer.DrawText(e.Graphics,
-                                                    post.TextSingleLine,
+                                                    post.IsDeleted ? "(DELETED)" : post.TextSingleLine,
                                                     e.Item.Font,
                                                     Rectangle.Round(rct),
                                                     color,
@@ -5121,30 +5127,39 @@ namespace OpenTween
                                                     TextFormatFlags.NoPrefix);
                         }
                     }
-                    else if (drawLineCount == 1)
-                    {
-                        TextRenderer.DrawText(e.Graphics,
-                                                e.ColumnIndex != 2 ? e.SubItem.Text : post.TextSingleLine,
-                                                e.Item.Font,
-                                                Rectangle.Round(rct),
-                                                color,
-                                                TextFormatFlags.SingleLine |
-                                                TextFormatFlags.EndEllipsis |
-                                                TextFormatFlags.GlyphOverhangPadding |
-                                                TextFormatFlags.NoPrefix |
-                                                TextFormatFlags.VerticalCenter);
-                    }
                     else
                     {
-                        TextRenderer.DrawText(e.Graphics,
-                                                e.ColumnIndex != 2 ? e.SubItem.Text : post.TextSingleLine,
-                                                e.Item.Font,
-                                                Rectangle.Round(rct),
-                                                color,
-                                                TextFormatFlags.WordBreak |
-                                                TextFormatFlags.EndEllipsis |
-                                                TextFormatFlags.GlyphOverhangPadding |
-                                                TextFormatFlags.NoPrefix);
+                        string text;
+                        if (e.ColumnIndex != 2)
+                            text = e.SubItem.Text;
+                        else
+                            text = post.IsDeleted ? "(DELETED)" : post.TextSingleLine;
+
+                        if (drawLineCount == 1)
+                        {
+                            TextRenderer.DrawText(e.Graphics,
+                                                    text,
+                                                    e.Item.Font,
+                                                    Rectangle.Round(rct),
+                                                    color,
+                                                    TextFormatFlags.SingleLine |
+                                                    TextFormatFlags.EndEllipsis |
+                                                    TextFormatFlags.GlyphOverhangPadding |
+                                                    TextFormatFlags.NoPrefix |
+                                                    TextFormatFlags.VerticalCenter);
+                        }
+                        else
+                        {
+                            TextRenderer.DrawText(e.Graphics,
+                                                    text,
+                                                    e.Item.Font,
+                                                    Rectangle.Round(rct),
+                                                    color,
+                                                    TextFormatFlags.WordBreak |
+                                                    TextFormatFlags.EndEllipsis |
+                                                    TextFormatFlags.GlyphOverhangPadding |
+                                                    TextFormatFlags.NoPrefix);
+                        }
                     }
                     //if (e.ColumnIndex == 6) this.DrawListViewItemStateIcon(e, rct);
                 }
@@ -5483,6 +5498,8 @@ namespace OpenTween
                 return;
 
             TabModel foundTab = null;
+            int foundIndex = 0;
+
             DetailsListView lst = null;
 
             //現在タブから最終タブまで探索
@@ -5490,11 +5507,13 @@ namespace OpenTween
             {
                 var tabPage = this.ListTab.TabPages[i];
                 var tab = this._statuses.Tabs[tabPage.Text];
+                var unreadIndex = tab.NextUnreadIndex;
 
-                if (tab.NextUnreadIndex != -1)
+                if (unreadIndex != -1)
                 {
                     ListTab.SelectedIndex = i;
                     foundTab = tab;
+                    foundIndex = unreadIndex;
                     lst = (DetailsListView)tabPage.Tag;
                     break;
                 }
@@ -5507,23 +5526,20 @@ namespace OpenTween
                 {
                     var tabPage = this.ListTab.TabPages[i];
                     var tab = this._statuses.Tabs[tabPage.Text];
+                    var unreadIndex = tab.NextUnreadIndex;
 
-                    if (tab.NextUnreadIndex != -1)
+                    if (unreadIndex != -1)
                     {
                         ListTab.SelectedIndex = i;
                         foundTab = tab;
+                        foundIndex = unreadIndex;
                         lst = (DetailsListView)tabPage.Tag;
                         break;
                     }
                 }
             }
 
-            int idx;
-            if (foundTab != null)
-            {
-                idx = foundTab.NextUnreadIndex;
-            }
-            else
+            if (foundTab == null)
             {
                 //全部調べたが未読見つからず→先頭タブの最新発言へ
                 ListTab.SelectedIndex = 0;
@@ -5534,30 +5550,30 @@ namespace OpenTween
                     return;
 
                 if (_statuses.SortOrder == SortOrder.Ascending)
-                    idx = tab.AllCount - 1;
+                    foundIndex = tab.AllCount - 1;
                 else
-                    idx = 0;
+                    foundIndex = 0;
 
                 lst = (DetailsListView)tabPage.Tag;
             }
 
-            SelectListItem(lst, idx);
+            SelectListItem(lst, foundIndex);
 
             if (_statuses.SortMode == ComparerMode.Id)
             {
-                if (_statuses.SortOrder == SortOrder.Ascending && lst.Items[idx].Position.Y > lst.ClientSize.Height - _iconSz - 10 ||
-                    _statuses.SortOrder == SortOrder.Descending && lst.Items[idx].Position.Y < _iconSz + 10)
+                if (_statuses.SortOrder == SortOrder.Ascending && lst.Items[foundIndex].Position.Y > lst.ClientSize.Height - _iconSz - 10 ||
+                    _statuses.SortOrder == SortOrder.Descending && lst.Items[foundIndex].Position.Y < _iconSz + 10)
                 {
                     MoveTop();
                 }
                 else
                 {
-                    lst.EnsureVisible(idx);
+                    lst.EnsureVisible(foundIndex);
                 }
             }
             else
             {
-                lst.EnsureVisible(idx);
+                lst.EnsureVisible(foundIndex);
             }
 
             lst.Focus();
@@ -6454,28 +6470,30 @@ namespace OpenTween
 
         private void CopyIdUri()
         {
-            string clstr = "";
-            StringBuilder sb = new StringBuilder();
-            if (this._curTab == null) return;
-            if (this._statuses.GetTabByName(this._curTab.Text) == null) return;
-            if (this._statuses.GetTabByName(this._curTab.Text).TabType == MyCommon.TabUsageType.DirectMessage) return;
+            if (this._curTab == null)
+                return;
+
+            var tab = this._statuses.GetTabByName(this._curTab.Text);
+            if (tab == null || tab is DirectMessagesTabModel)
+                return;
+
+            var copyUrls = new List<string>();
             foreach (int idx in _curList.SelectedIndices)
             {
-                var post = _statuses.Tabs[_curTab.Text][idx];
-                sb.Append(MyCommon.GetStatusUrl(post));
-                sb.Append(Environment.NewLine);
+                var post = tab[idx];
+                copyUrls.Add(MyCommon.GetStatusUrl(post));
             }
-            if (sb.Length > 0)
+
+            if (copyUrls.Count == 0)
+                return;
+
+            try
             {
-                clstr = sb.ToString();
-                try
-                {
-                    Clipboard.SetDataObject(clstr, false, 5, 100);
-                }
-                catch (Exception ex)
-                {
-                    MessageBox.Show(ex.Message);
-                }
+                Clipboard.SetDataObject(string.Join(Environment.NewLine, copyUrls), false, 5, 100);
+            }
+            catch (ExternalException ex)
+            {
+                MessageBox.Show(ex.Message);
             }
         }
 
@@ -7180,8 +7198,8 @@ namespace OpenTween
             if (_ignoreConfigSave || !this._cfgCommon.UseAtIdSupplement && AtIdSupl == null) return;
 
             ModifySettingAtId = false;
-            SettingAtIdList cfgAtId = new SettingAtIdList(AtIdSupl.GetItemList());
-            cfgAtId.Save();
+            SettingManager.AtIdList.AtIdList = this.AtIdSupl.GetItemList();
+            SettingManager.SaveAtIdList();
         }
 
         private void SaveConfigsCommon()
@@ -7244,7 +7262,7 @@ namespace OpenTween
                 _cfgCommon.UseImageService = ImageSelector.ServiceIndex;
                 _cfgCommon.UseImageServiceName = ImageSelector.ServiceName;
 
-                _cfgCommon.Save();
+                SettingManager.SaveCommon();
             }
         }
 
@@ -7285,13 +7303,13 @@ namespace OpenTween
                 _cfgLocal.FontInputFont = _fntInputFont;
 
                 if (_ignoreConfigSave) return;
-                _cfgLocal.Save();
+                SettingManager.SaveLocal();
             }
         }
 
         private void SaveConfigsTabs()
         {
-            var tabsSetting = new SettingTabs();
+            var tabSettingList = new List<SettingTabs.SettingTabItem>();
 
             var tabs = this.ListTab.TabPages.Cast<TabPage>()
                 .Select(x => this._statuses.Tabs[x.Text])
@@ -7331,10 +7349,11 @@ namespace OpenTween
                 if (listTab != null)
                     tabSetting.ListInfo = listTab.ListInfo;
 
-                tabsSetting.Tabs.Add(tabSetting);
+                tabSettingList.Add(tabSetting);
             }
 
-            tabsSetting.Save();
+            SettingManager.Tabs.Tabs = tabSettingList;
+            SettingManager.SaveTabs();
         }
 
         private async void OpenURLFileMenuItem_Click(object sender, EventArgs e)
@@ -7448,24 +7467,12 @@ namespace OpenTween
                 }
 
                 var tabPage = this.ListTab.TabPages.Cast<TabPage>()
-                    .First(x => x.Text == origTabName);
+                    .FirstOrDefault(x => x.Text == origTabName);
 
-                ListViewScroll scrollInfo;
-                if (this.listViewScroll.TryGetValue(origTabName, out scrollInfo))
-                {
-                    this.listViewScroll.Remove(origTabName);
-                    this.listViewScroll[newTabName] = scrollInfo;
-                }
+                // タブ名を変更
+                if (tabPage != null)
+                    tabPage.Text = newTabName;
 
-                ListViewSelection selectionInfo;
-                if (this.listViewSelection.TryGetValue(origTabName, out selectionInfo))
-                {
-                    this.listViewSelection.Remove(origTabName);
-                    this.listViewSelection[newTabName] = selectionInfo;
-                }
-
-                //タブ名を変更
-                tabPage.Text = newTabName;
                 _statuses.RenameTab(origTabName, newTabName);
 
                 SaveConfigsCommon();
@@ -9866,35 +9873,11 @@ namespace OpenTween
         {
             SetListProperty();
 
-            if (this._curList != null)
-            {
-                var beforeSelectedList = this._curList;
-                var beforeSelectedTabModel = this._statuses.Tabs[this._curTab.Text];
-
-                // 発言一覧のスクロール位置・選択状態を退避
-                this.listViewScroll[beforeSelectedTabModel.TabName] = this.SaveListViewScroll(beforeSelectedList, beforeSelectedTabModel);
-                this.listViewSelection[beforeSelectedTabModel.TabName] = this.SaveListViewSelection(beforeSelectedList, beforeSelectedTabModel);
-            }
-
             this.PurgeListViewItemCache();
 
             _curTab = _tab;
             _curList = (DetailsListView)_tab.Tag;
 
-            var curTabModel = this._statuses.Tabs[this._curTab.Text];
-
-            this._curList.VirtualListSize = curTabModel.AllCount;
-
-            // 発言一覧のスクロール位置を復元
-            ListViewScroll scrollInfo;
-            if (this.listViewScroll.TryGetValue(curTabModel.TabName, out scrollInfo))
-                this.RestoreListViewScroll(this._curList, curTabModel, scrollInfo);
-
-            // 発言一覧の選択状態を復元
-            ListViewSelection selectionInfo;
-            if (this.listViewSelection.TryGetValue(curTabModel.TabName, out selectionInfo))
-                this.RestoreListViewSelection(this._curList, curTabModel, selectionInfo);
-
             if (_curList.SelectedIndices.Count > 0)
             {
                 _curItemIndex = _curList.SelectedIndices[0];
@@ -10110,9 +10093,11 @@ namespace OpenTween
             //公式RT
             if (this.ExistCurrentPost)
             {
-                if (_curPost.IsProtect)
+                if (!_curPost.CanRetweetBy(this.twitterApi.CurrentUserId))
                 {
-                    MessageBox.Show("Protected.");
+                    if (this._curPost.IsProtect)
+                        MessageBox.Show("Protected.");
+
                     _DoFavRetweetFlags = false;
                     return;
                 }
@@ -10136,11 +10121,6 @@ namespace OpenTween
                 }
                 else
                 {
-                    if (_curPost.IsDm)
-                    {
-                        _DoFavRetweetFlags = false;
-                        return;
-                    }
                     if (!this._cfgCommon.RetweetNoConfirm)
                     {
                         string Questiontext = Properties.Resources.RetweetQuestion1;
@@ -10157,7 +10137,7 @@ namespace OpenTween
                 foreach (int idx in _curList.SelectedIndices)
                 {
                     PostClass post = GetCurTabPost(idx);
-                    if (!post.IsProtect && !post.IsDm)
+                    if (post.CanRetweetBy(this.twitterApi.CurrentUserId))
                         statusIds.Add(post.StatusId);
                 }
 
@@ -10829,38 +10809,16 @@ namespace OpenTween
             await this.doMoveToRTHome();
         }
 
-        private async void ListManageUserContextToolStripMenuItem_Click(object sender, EventArgs e)
+        private void ListManageUserContextToolStripMenuItem_Click(object sender, EventArgs e)
         {
             var screenName = this._curPost?.ScreenName;
             if (screenName != null)
-                await this.ListManageUserContext(screenName);
+                this.ListManageUserContext(screenName);
         }
 
-        public async Task ListManageUserContext(string screenName)
+        public void ListManageUserContext(string screenName)
         {
-            if (this._statuses.SubscribableLists.Count == 0)
-            {
-                try
-                {
-                    using (var dialog = new WaitingDialog(Properties.Resources.ListsGetting))
-                    {
-                        var cancellationToken = dialog.EnableCancellation();
-
-                        var task = this.tw.GetListsApi();
-                        await dialog.WaitForAsync(this, task);
-
-                        cancellationToken.ThrowIfCancellationRequested();
-                    }
-                }
-                catch (OperationCanceledException) { return; }
-                catch (WebApiException ex)
-                {
-                    MessageBox.Show("Failed to get lists. (" + ex.Message + ")");
-                    return;
-                }
-            }
-
-            using (MyLists listSelectForm = new MyLists(screenName, this.tw))
+            using (var listSelectForm = new MyLists(screenName, this.twitterApi))
             {
                 listSelectForm.ShowDialog(this);
             }
@@ -11031,7 +10989,7 @@ namespace OpenTween
                 this.OpenFavotterOpMenuItem.Enabled = true;
                 this.ShowRelatedStatusesMenuItem2.Enabled = true;  //PublicSearchの時問題出るかも
 
-                if (_curPost.IsProtect)
+                if (!_curPost.CanRetweetBy(this.twitterApi.CurrentUserId))
                 {
                     this.RtOpMenuItem.Enabled = false;
                     this.RtUnOpMenuItem.Enabled = false;
@@ -11392,8 +11350,7 @@ namespace OpenTween
                 ModifySettingCommon = true;
                 SaveConfigsAll(true);
 
-                if (ImageSelector.ServiceName.Equals("Twitter"))
-                    this.StatusText_TextChanged(null, null);
+                this.StatusText_TextChanged(null, null);
             }
         }