From 1f92d5e63306d454e396cf0288b37d9e5ac28db6 Mon Sep 17 00:00:00 2001
From: chylex <contact@chylex.com>
Date: Wed, 28 Feb 2018 01:43:44 +0100
Subject: [PATCH] Remove 'Shift Selects Multiple Accounts' option & fix
 refocusing after switching account

---
 Configuration/UserConfig.cs                   |  1 -
 Core/Bridge/PropertyBridge.cs                 |  1 -
 .../Analytics/AnalyticsReportGenerator.cs     |  2 +-
 .../Settings/TabSettingsGeneral.Designer.cs   | 44 +++++++------------
 Core/Other/Settings/TabSettingsGeneral.cs     |  7 ---
 Resources/Scripts/code.js                     | 19 ++------
 6 files changed, 20 insertions(+), 54 deletions(-)

diff --git a/Configuration/UserConfig.cs b/Configuration/UserConfig.cs
index 22ad7f49..c608ee60 100644
--- a/Configuration/UserConfig.cs
+++ b/Configuration/UserConfig.cs
@@ -42,7 +42,6 @@ static UserConfig(){
         public WindowState PluginsWindow { get; set; } = new WindowState();
 
         public bool ExpandLinksOnHover        { get; set; } = true;
-        public bool SwitchAccountSelectors    { get; set; } = true;
         public bool OpenSearchInFirstColumn   { get; set; } = true;
         public bool KeepLikeFollowDialogsOpen { get; set; } = true;
         public bool BestImageQuality          { get; set; } = true;
diff --git a/Core/Bridge/PropertyBridge.cs b/Core/Bridge/PropertyBridge.cs
index cfcbafdf..8ab153f0 100644
--- a/Core/Bridge/PropertyBridge.cs
+++ b/Core/Bridge/PropertyBridge.cs
@@ -15,7 +15,6 @@ public static string GenerateScript(Environment environment){
             build.Append("x.expandLinksOnHover=").Append(Bool(Program.UserConfig.ExpandLinksOnHover));
             
             if (environment == Environment.Browser){
-                build.Append("x.switchAccountSelectors=").Append(Bool(Program.UserConfig.SwitchAccountSelectors));
                 build.Append("x.openSearchInFirstColumn=").Append(Bool(Program.UserConfig.OpenSearchInFirstColumn));
                 build.Append("x.keepLikeFollowDialogsOpen=").Append(Bool(Program.UserConfig.KeepLikeFollowDialogsOpen));
                 build.Append("x.muteNotifications=").Append(Bool(Program.UserConfig.MuteNotifications));
diff --git a/Core/Other/Analytics/AnalyticsReportGenerator.cs b/Core/Other/Analytics/AnalyticsReportGenerator.cs
index a53966a6..0c6ba8e5 100644
--- a/Core/Other/Analytics/AnalyticsReportGenerator.cs
+++ b/Core/Other/Analytics/AnalyticsReportGenerator.cs
@@ -42,7 +42,7 @@ public static AnalyticsReport Create(AnalyticsFile file, ExternalInfo info, Plug
                 { "Clear Cache Threshold"     , Exact(SysConfig.ClearCacheThreshold) },
                 0,
                 { "Expand Links"                  , Bool(UserConfig.ExpandLinksOnHover) },
-                { "Switch Account Selectors"      , Bool(UserConfig.SwitchAccountSelectors) },
+                { "Switch Account Selectors"      , Bool(false) }, // TODO remove in next major update
                 { "Search In First Column"        , Bool(UserConfig.OpenSearchInFirstColumn) },
                 { "Keep Like Follow Dialogs Open" , Bool(UserConfig.KeepLikeFollowDialogsOpen) },
                 { "Best Image Quality"            , Bool(UserConfig.BestImageQuality) },
diff --git a/Core/Other/Settings/TabSettingsGeneral.Designer.cs b/Core/Other/Settings/TabSettingsGeneral.Designer.cs
index cebab1c6..76b87f91 100644
--- a/Core/Other/Settings/TabSettingsGeneral.Designer.cs
+++ b/Core/Other/Settings/TabSettingsGeneral.Designer.cs
@@ -29,7 +29,6 @@ private void InitializeComponent() {
             this.checkUpdateNotifications = new System.Windows.Forms.CheckBox();
             this.btnCheckUpdates = new System.Windows.Forms.Button();
             this.labelZoomValue = new System.Windows.Forms.Label();
-            this.checkSwitchAccountSelectors = new System.Windows.Forms.CheckBox();
             this.checkBestImageQuality = new System.Windows.Forms.CheckBox();
             this.checkOpenSearchInFirstColumn = new System.Windows.Forms.CheckBox();
             this.trackBarZoom = new System.Windows.Forms.TrackBar();
@@ -64,7 +63,7 @@ private void InitializeComponent() {
             // checkUpdateNotifications
             // 
             this.checkUpdateNotifications.AutoSize = true;
-            this.checkUpdateNotifications.Location = new System.Drawing.Point(6, 386);
+            this.checkUpdateNotifications.Location = new System.Drawing.Point(6, 363);
             this.checkUpdateNotifications.Margin = new System.Windows.Forms.Padding(6, 6, 3, 3);
             this.checkUpdateNotifications.Name = "checkUpdateNotifications";
             this.checkUpdateNotifications.Size = new System.Drawing.Size(165, 17);
@@ -74,7 +73,7 @@ private void InitializeComponent() {
             // 
             // btnCheckUpdates
             // 
-            this.btnCheckUpdates.Location = new System.Drawing.Point(5, 409);
+            this.btnCheckUpdates.Location = new System.Drawing.Point(5, 386);
             this.btnCheckUpdates.Margin = new System.Windows.Forms.Padding(5, 3, 3, 3);
             this.btnCheckUpdates.Name = "btnCheckUpdates";
             this.btnCheckUpdates.Size = new System.Drawing.Size(144, 23);
@@ -93,21 +92,10 @@ private void InitializeComponent() {
             this.labelZoomValue.Text = "100%";
             this.labelZoomValue.TextAlign = System.Drawing.ContentAlignment.TopRight;
             // 
-            // checkSwitchAccountSelectors
-            // 
-            this.checkSwitchAccountSelectors.AutoSize = true;
-            this.checkSwitchAccountSelectors.Location = new System.Drawing.Point(6, 49);
-            this.checkSwitchAccountSelectors.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
-            this.checkSwitchAccountSelectors.Name = "checkSwitchAccountSelectors";
-            this.checkSwitchAccountSelectors.Size = new System.Drawing.Size(172, 17);
-            this.checkSwitchAccountSelectors.TabIndex = 2;
-            this.checkSwitchAccountSelectors.Text = "Shift Selects Multiple Accounts";
-            this.checkSwitchAccountSelectors.UseVisualStyleBackColor = true;
-            // 
             // checkBestImageQuality
             // 
             this.checkBestImageQuality.AutoSize = true;
-            this.checkBestImageQuality.Location = new System.Drawing.Point(6, 118);
+            this.checkBestImageQuality.Location = new System.Drawing.Point(6, 95);
             this.checkBestImageQuality.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
             this.checkBestImageQuality.Name = "checkBestImageQuality";
             this.checkBestImageQuality.Size = new System.Drawing.Size(114, 17);
@@ -118,7 +106,7 @@ private void InitializeComponent() {
             // checkOpenSearchInFirstColumn
             // 
             this.checkOpenSearchInFirstColumn.AutoSize = true;
-            this.checkOpenSearchInFirstColumn.Location = new System.Drawing.Point(6, 72);
+            this.checkOpenSearchInFirstColumn.Location = new System.Drawing.Point(6, 49);
             this.checkOpenSearchInFirstColumn.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
             this.checkOpenSearchInFirstColumn.Name = "checkOpenSearchInFirstColumn";
             this.checkOpenSearchInFirstColumn.Size = new System.Drawing.Size(219, 17);
@@ -144,7 +132,7 @@ private void InitializeComponent() {
             // labelZoom
             // 
             this.labelZoom.AutoSize = true;
-            this.labelZoom.Location = new System.Drawing.Point(3, 291);
+            this.labelZoom.Location = new System.Drawing.Point(3, 268);
             this.labelZoom.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
             this.labelZoom.Name = "labelZoom";
             this.labelZoom.Size = new System.Drawing.Size(34, 13);
@@ -172,7 +160,7 @@ private void InitializeComponent() {
             this.panelZoom.Anchor = System.Windows.Forms.AnchorStyles.Top;
             this.panelZoom.Controls.Add(this.trackBarZoom);
             this.panelZoom.Controls.Add(this.labelZoomValue);
-            this.panelZoom.Location = new System.Drawing.Point(0, 304);
+            this.panelZoom.Location = new System.Drawing.Point(0, 281);
             this.panelZoom.Margin = new System.Windows.Forms.Padding(0);
             this.panelZoom.Name = "panelZoom";
             this.panelZoom.Size = new System.Drawing.Size(322, 36);
@@ -181,7 +169,7 @@ private void InitializeComponent() {
             // checkAnimatedAvatars
             // 
             this.checkAnimatedAvatars.AutoSize = true;
-            this.checkAnimatedAvatars.Location = new System.Drawing.Point(6, 141);
+            this.checkAnimatedAvatars.Location = new System.Drawing.Point(6, 118);
             this.checkAnimatedAvatars.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
             this.checkAnimatedAvatars.Name = "checkAnimatedAvatars";
             this.checkAnimatedAvatars.Size = new System.Drawing.Size(145, 17);
@@ -193,7 +181,7 @@ private void InitializeComponent() {
             // 
             this.labelUpdates.AutoSize = true;
             this.labelUpdates.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
-            this.labelUpdates.Location = new System.Drawing.Point(0, 360);
+            this.labelUpdates.Location = new System.Drawing.Point(0, 337);
             this.labelUpdates.Margin = new System.Windows.Forms.Padding(0, 20, 0, 0);
             this.labelUpdates.Name = "labelUpdates";
             this.labelUpdates.Size = new System.Drawing.Size(70, 20);
@@ -207,7 +195,6 @@ private void InitializeComponent() {
             | System.Windows.Forms.AnchorStyles.Right)));
             this.flowPanel.Controls.Add(this.labelUI);
             this.flowPanel.Controls.Add(this.checkExpandLinks);
-            this.flowPanel.Controls.Add(this.checkSwitchAccountSelectors);
             this.flowPanel.Controls.Add(this.checkOpenSearchInFirstColumn);
             this.flowPanel.Controls.Add(this.checkKeepLikeFollowDialogsOpen);
             this.flowPanel.Controls.Add(this.checkBestImageQuality);
@@ -224,14 +211,14 @@ private void InitializeComponent() {
             this.flowPanel.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
             this.flowPanel.Location = new System.Drawing.Point(9, 9);
             this.flowPanel.Name = "flowPanel";
-            this.flowPanel.Size = new System.Drawing.Size(322, 438);
+            this.flowPanel.Size = new System.Drawing.Size(322, 415);
             this.flowPanel.TabIndex = 0;
             this.flowPanel.WrapContents = false;
             // 
             // checkKeepLikeFollowDialogsOpen
             // 
             this.checkKeepLikeFollowDialogsOpen.AutoSize = true;
-            this.checkKeepLikeFollowDialogsOpen.Location = new System.Drawing.Point(6, 95);
+            this.checkKeepLikeFollowDialogsOpen.Location = new System.Drawing.Point(6, 72);
             this.checkKeepLikeFollowDialogsOpen.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
             this.checkKeepLikeFollowDialogsOpen.Name = "checkKeepLikeFollowDialogsOpen";
             this.checkKeepLikeFollowDialogsOpen.Size = new System.Drawing.Size(176, 17);
@@ -243,7 +230,7 @@ private void InitializeComponent() {
             // 
             this.labelBrowserSettings.AutoSize = true;
             this.labelBrowserSettings.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
-            this.labelBrowserSettings.Location = new System.Drawing.Point(0, 181);
+            this.labelBrowserSettings.Location = new System.Drawing.Point(0, 158);
             this.labelBrowserSettings.Margin = new System.Windows.Forms.Padding(0, 20, 0, 0);
             this.labelBrowserSettings.Name = "labelBrowserSettings";
             this.labelBrowserSettings.Size = new System.Drawing.Size(130, 20);
@@ -253,7 +240,7 @@ private void InitializeComponent() {
             // checkSmoothScrolling
             // 
             this.checkSmoothScrolling.AutoSize = true;
-            this.checkSmoothScrolling.Location = new System.Drawing.Point(6, 207);
+            this.checkSmoothScrolling.Location = new System.Drawing.Point(6, 184);
             this.checkSmoothScrolling.Margin = new System.Windows.Forms.Padding(6, 6, 3, 3);
             this.checkSmoothScrolling.Name = "checkSmoothScrolling";
             this.checkSmoothScrolling.Size = new System.Drawing.Size(105, 17);
@@ -264,7 +251,7 @@ private void InitializeComponent() {
             // labelBrowserPath
             // 
             this.labelBrowserPath.AutoSize = true;
-            this.labelBrowserPath.Location = new System.Drawing.Point(3, 239);
+            this.labelBrowserPath.Location = new System.Drawing.Point(3, 216);
             this.labelBrowserPath.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
             this.labelBrowserPath.Name = "labelBrowserPath";
             this.labelBrowserPath.Size = new System.Drawing.Size(95, 13);
@@ -275,7 +262,7 @@ private void InitializeComponent() {
             // 
             this.comboBoxBrowserPath.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
             this.comboBoxBrowserPath.FormattingEnabled = true;
-            this.comboBoxBrowserPath.Location = new System.Drawing.Point(5, 255);
+            this.comboBoxBrowserPath.Location = new System.Drawing.Point(5, 232);
             this.comboBoxBrowserPath.Margin = new System.Windows.Forms.Padding(5, 3, 3, 3);
             this.comboBoxBrowserPath.Name = "comboBoxBrowserPath";
             this.comboBoxBrowserPath.Size = new System.Drawing.Size(173, 21);
@@ -287,7 +274,7 @@ private void InitializeComponent() {
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.Controls.Add(this.flowPanel);
             this.Name = "TabSettingsGeneral";
-            this.Size = new System.Drawing.Size(340, 456);
+            this.Size = new System.Drawing.Size(340, 433);
             ((System.ComponentModel.ISupportInitialize)(this.trackBarZoom)).EndInit();
             this.panelZoom.ResumeLayout(false);
             this.flowPanel.ResumeLayout(false);
@@ -306,7 +293,6 @@ private void InitializeComponent() {
         private System.Windows.Forms.Label labelZoomValue;
         private System.Windows.Forms.TrackBar trackBarZoom;
         private System.Windows.Forms.Timer zoomUpdateTimer;
-        private System.Windows.Forms.CheckBox checkSwitchAccountSelectors;
         private System.Windows.Forms.Label labelUI;
         private System.Windows.Forms.Panel panelZoom;
         private System.Windows.Forms.Label labelUpdates;
diff --git a/Core/Other/Settings/TabSettingsGeneral.cs b/Core/Other/Settings/TabSettingsGeneral.cs
index 9f0bcfdc..2201751d 100644
--- a/Core/Other/Settings/TabSettingsGeneral.cs
+++ b/Core/Other/Settings/TabSettingsGeneral.cs
@@ -26,7 +26,6 @@ public TabSettingsGeneral(FormBrowser browser, UpdateHandler updates){
             Disposed += (sender, args) => this.updates.CheckFinished -= updates_CheckFinished;
             
             toolTip.SetToolTip(checkExpandLinks, "Expands links inside the tweets. If disabled,\r\nthe full links show up in a tooltip instead.");
-            toolTip.SetToolTip(checkSwitchAccountSelectors, "When (re)tweeting, click to select a single account or hold Shift to\r\nselect multiple accounts, instead of TweetDeck\'s default behavior.");
             toolTip.SetToolTip(checkOpenSearchInFirstColumn, "By default, TweetDeck adds Search columns at the end.\r\nThis option makes them appear before the first column instead.");
             toolTip.SetToolTip(checkKeepLikeFollowDialogsOpen, "Allows liking and following from multiple accounts at once,\r\ninstead of automatically closing the dialog after taking an action.");
             toolTip.SetToolTip(checkBestImageQuality, "When right-clicking a tweet image, the context menu options\r\nwill use links to the original image size (:orig in the URL).");
@@ -41,7 +40,6 @@ public TabSettingsGeneral(FormBrowser browser, UpdateHandler updates){
             toolTip.SetToolTip(btnCheckUpdates, "Forces an update check, even for updates that had been dismissed.");
 
             checkExpandLinks.Checked = Config.ExpandLinksOnHover;
-            checkSwitchAccountSelectors.Checked = Config.SwitchAccountSelectors;
             checkOpenSearchInFirstColumn.Checked = Config.OpenSearchInFirstColumn;
             checkKeepLikeFollowDialogsOpen.Checked = Config.KeepLikeFollowDialogsOpen;
             checkBestImageQuality.Checked = Config.BestImageQuality;
@@ -65,7 +63,6 @@ public TabSettingsGeneral(FormBrowser browser, UpdateHandler updates){
 
         public override void OnReady(){
             checkExpandLinks.CheckedChanged += checkExpandLinks_CheckedChanged;
-            checkSwitchAccountSelectors.CheckedChanged += checkSwitchAccountSelectors_CheckedChanged;
             checkOpenSearchInFirstColumn.CheckedChanged += checkOpenSearchInFirstColumn_CheckedChanged;
             checkKeepLikeFollowDialogsOpen.CheckedChanged += checkKeepLikeFollowDialogsOpen_CheckedChanged;
             checkBestImageQuality.CheckedChanged += checkBestImageQuality_CheckedChanged;
@@ -87,10 +84,6 @@ private void checkExpandLinks_CheckedChanged(object sender, EventArgs e){
             Config.ExpandLinksOnHover = checkExpandLinks.Checked;
         }
 
-        private void checkSwitchAccountSelectors_CheckedChanged(object sender, EventArgs e){
-            Config.SwitchAccountSelectors = checkSwitchAccountSelectors.Checked;
-        }
-
         private void checkOpenSearchInFirstColumn_CheckedChanged(object sender, EventArgs e){
             Config.OpenSearchInFirstColumn = checkOpenSearchInFirstColumn.Checked;
         }
diff --git a/Resources/Scripts/code.js b/Resources/Scripts/code.js
index 58937e46..da730911 100644
--- a/Resources/Scripts/code.js
+++ b/Resources/Scripts/code.js
@@ -928,26 +928,15 @@
   })();
   
   //
-  // Block: Swap shift key functionality for selecting accounts, and refocus the textbox afterwards.
+  // Block: Refocus the textbox after switching accounts.
   //
   onAppReady.push(function(){
-    const onAccountClick = function(e){
-      if ($TDX.switchAccountSelectors){
-        e.shiftKey = !e.shiftKey;
-      }
-      
+    const refocusInput = function(){
       $(".js-compose-text", ".js-docked-compose").focus();
     };
     
-    $(".js-account-list", ".js-docked-compose").delegate(".js-account-item", "click", onAccountClick);
-    
-    return if !ensurePropertyExists(TD, "components", "AccountSelector", "prototype", "refreshPostingAccounts");
-    
-    TD.components.AccountSelector.prototype.refreshPostingAccounts = appendToFunction(TD.components.AccountSelector.prototype.refreshPostingAccounts, function(){
-      if (!this.$node.attr("td-account-selector-hook")){
-        this.$node.attr("td-account-selector-hook", "1");
-        this.$node.delegate(".js-account-item", "click", onAccountClick);
-      }
+    $(".js-account-list", ".js-docked-compose").delegate(".js-account-item", "click", function(e){
+      setTimeout(refocusInput, 0);
     });
   });