From d7ad62d4765f0ceaa7ef0e35c34e8f9d39c0262f Mon Sep 17 00:00:00 2001
From: chylex <contact@chylex.com>
Date: Mon, 28 Aug 2017 22:38:11 +0200
Subject: [PATCH] Make TweetNotification use persistent column ID

---
 Core/FormBrowser.cs                       | 4 ++--
 Core/Notification/FormNotificationBase.cs | 2 +-
 Core/Notification/TweetNotification.cs    | 8 ++++----
 Resources/Scripts/code.js                 | 6 +++---
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/Core/FormBrowser.cs b/Core/FormBrowser.cs
index 38b47e6f..68e4f88f 100644
--- a/Core/FormBrowser.cs
+++ b/Core/FormBrowser.cs
@@ -543,7 +543,7 @@ public bool ProcessBrowserKey(Keys key){
             return false;
         }
 
-        public void ShowTweetDetail(string columnKey, string chirpId, string fallbackUrl){
+        public void ShowTweetDetail(string columnId, string chirpId, string fallbackUrl){
             Activate();
 
             using(IFrame frame = browser.GetBrowser().MainFrame){
@@ -554,7 +554,7 @@ public void ShowTweetDetail(string columnKey, string chirpId, string fallbackUrl
             }
 
             notification.FinishCurrentNotification();
-            browser.ExecuteScriptAsync("window.TDGF_showTweetDetail", columnKey, chirpId, fallbackUrl);
+            browser.ExecuteScriptAsync("window.TDGF_showTweetDetail", columnId, chirpId, fallbackUrl);
         }
 
         public void OnTweetScreenshotReady(string html, int width, int height){
diff --git a/Core/Notification/FormNotificationBase.cs b/Core/Notification/FormNotificationBase.cs
index 464d15e7..a0a637a9 100644
--- a/Core/Notification/FormNotificationBase.cs
+++ b/Core/Notification/FormNotificationBase.cs
@@ -197,7 +197,7 @@ protected virtual void UpdateTitle(){
         }
 
         public void ShowTweetDetail(){
-            owner.ShowTweetDetail(currentNotification.ColumnKey, currentNotification.ChirpId, currentNotification.TweetUrl);
+            owner.ShowTweetDetail(currentNotification.ColumnId, currentNotification.ChirpId, currentNotification.TweetUrl);
         }
 
         public void MoveToVisibleLocation(){
diff --git a/Core/Notification/TweetNotification.cs b/Core/Notification/TweetNotification.cs
index f48206d1..32463daa 100644
--- a/Core/Notification/TweetNotification.cs
+++ b/Core/Notification/TweetNotification.cs
@@ -55,7 +55,7 @@ public enum Size{
             Auto, Custom
         }
 
-        public string ColumnKey { get; }
+        public string ColumnId { get; }
         public string ChirpId { get; }
 
         public string ColumnTitle { get; }
@@ -66,10 +66,10 @@ public enum Size{
         private readonly int characters;
         private readonly bool isExample;
 
-        public TweetNotification(string columnKey, string chirpId, string title, string html, int characters, string tweetUrl, string quoteUrl) : this(columnKey, chirpId, title, html, characters, tweetUrl, quoteUrl, false){}
+        public TweetNotification(string columnId, string chirpId, string title, string html, int characters, string tweetUrl, string quoteUrl) : this(columnId, chirpId, title, html, characters, tweetUrl, quoteUrl, false){}
 
-        private TweetNotification(string columnKey, string chirpId, string title, string html, int characters, string tweetUrl, string quoteUrl, bool isExample){
-            this.ColumnKey = columnKey;
+        private TweetNotification(string columnId, string chirpId, string title, string html, int characters, string tweetUrl, string quoteUrl, bool isExample){
+            this.ColumnId = columnId;
             this.ChirpId = chirpId;
 
             this.ColumnTitle = title;
diff --git a/Resources/Scripts/code.js b/Resources/Scripts/code.js
index a6eb6e02..2771fcc9 100644
--- a/Resources/Scripts/code.js
+++ b/Resources/Scripts/code.js
@@ -201,7 +201,7 @@
         let tweetUrl = source ? source.getChirpURL() : "";
         let quoteUrl = source && source.quotedTweet ? source.quotedTweet.getChirpURL() : "";
 
-        $TD.onTweetPopup(column.model.privateState.key, chirpId, columnTypes[column.getColumnType()] || "", html.html(), duration, tweetUrl, quoteUrl);
+        $TD.onTweetPopup(column.model.privateState.apiid, chirpId, columnTypes[column.getColumnType()] || "", html.html(), duration, tweetUrl, quoteUrl);
       }
 
       if (column.model.getHasSound()){
@@ -221,8 +221,8 @@
       $(document).trigger("uiGridClearSelection");
     };
     
-    window.TDGF_showTweetDetail = function(columnKey, chirpId, fallbackUrl){
-      let column = TD.controller.columnManager.get(columnKey); // TODO replace columnKey with something that stays after a reload
+    window.TDGF_showTweetDetail = function(columnId, chirpId, fallbackUrl){
+      let column = TD.controller.columnManager.getByApiid(columnId);
       
       if (!column){
         if (confirm("error|The column which contained the tweet no longer exists. Would you like to open the tweet in your browser instead?")){