From 87fd2a521ee9136cf41037b8e3ef8c47c52fb033 Mon Sep 17 00:00:00 2001
From: chylex <info@chylex.com>
Date: Fri, 21 Oct 2016 06:50:34 +0200
Subject: [PATCH] Fix quoted tweet link in notification window not resetting

Closes #75
---
 Core/FormNotification.cs                 |  2 ++
 Core/Handling/ContextMenuNotification.cs | 10 +++++-----
 Core/Handling/TweetDeckBridge.cs         |  5 ++---
 Resources/Scripts/notification.js        |  2 +-
 4 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/Core/FormNotification.cs b/Core/FormNotification.cs
index 193a41ac..82a8346d 100644
--- a/Core/FormNotification.cs
+++ b/Core/FormNotification.cs
@@ -62,6 +62,7 @@ protected override bool ShowWithoutActivation{
         public bool FreezeTimer { get; set; }
         public bool ContextMenuOpen { get; set; }
         public string CurrentUrl { get; private set; }
+        public string CurrentQuotedTweetUrl { get; set; }
 
         public EventHandler Initialized;
         private bool isInitialized;
@@ -277,6 +278,7 @@ private void LoadNextNotification(){
 
         private void LoadTweet(TweetNotification tweet){
             CurrentUrl = tweet.Url;
+            CurrentQuotedTweetUrl = string.Empty; // load from JS
             
             timerProgress.Stop();
             totalTime = timeLeft = tweet.GetDisplayDuration(Program.UserConfig.NotificationDurationValue);
diff --git a/Core/Handling/ContextMenuNotification.cs b/Core/Handling/ContextMenuNotification.cs
index 7e0f97eb..bc062dc9 100644
--- a/Core/Handling/ContextMenuNotification.cs
+++ b/Core/Handling/ContextMenuNotification.cs
@@ -7,7 +7,7 @@ class ContextMenuNotification : ContextMenuBase{
         private const int MenuSkipTweet = 26600;
         private const int MenuFreeze = 26601;
         private const int MenuCopyTweetUrl = 26602;
-        private const int MenuCopyTweetEmbeddedUrl = 26603;
+        private const int MenuCopyQuotedTweetUrl = 26603;
 
         private readonly FormNotification form;
         private readonly bool enableCustomMenu;
@@ -29,8 +29,8 @@ public override void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser br
                 if (!string.IsNullOrEmpty(form.CurrentUrl)){
                     model.AddItem((CefMenuCommand)MenuCopyTweetUrl, "Copy tweet address");
 
-                    if (!string.IsNullOrEmpty(TweetDeckBridge.NotificationTweetEmbedded)){
-                        model.AddItem((CefMenuCommand)MenuCopyTweetEmbeddedUrl, "Copy quoted tweet address");
+                    if (!string.IsNullOrEmpty(form.CurrentQuotedTweetUrl)){
+                        model.AddItem((CefMenuCommand)MenuCopyQuotedTweetUrl, "Copy quoted tweet address");
                     }
 
                     model.AddSeparator();
@@ -61,8 +61,8 @@ public override bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser b
                     Clipboard.SetText(form.CurrentUrl, TextDataFormat.UnicodeText);
                     return true;
 
-                case MenuCopyTweetEmbeddedUrl:
-                    Clipboard.SetText(TweetDeckBridge.NotificationTweetEmbedded, TextDataFormat.UnicodeText);
+                case MenuCopyQuotedTweetUrl:
+                    Clipboard.SetText(form.CurrentQuotedTweetUrl, TextDataFormat.UnicodeText);
                     return true;
             }
 
diff --git a/Core/Handling/TweetDeckBridge.cs b/Core/Handling/TweetDeckBridge.cs
index 270b949b..6d645876 100644
--- a/Core/Handling/TweetDeckBridge.cs
+++ b/Core/Handling/TweetDeckBridge.cs
@@ -11,7 +11,6 @@ class TweetDeckBridge{
         public static string LastRightClickedLink = string.Empty;
         public static string LastHighlightedTweet = string.Empty;
         public static string LastHighlightedQuotedTweet = string.Empty;
-        public static string NotificationTweetEmbedded = string.Empty;
         public static string ClipboardImagePath = string.Empty;
 
         private readonly FormBrowser form;
@@ -81,8 +80,8 @@ public void SetLastHighlightedTweet(string link, string quotedLink){
             });
         }
 
-        public void SetNotificationTweetEmbedded(string link){
-            form.InvokeSafe(() => NotificationTweetEmbedded = link);
+        public void SetNotificationQuotedTweet(string link){
+            notification.InvokeSafe(() => notification.CurrentQuotedTweetUrl = link);
         }
 
         public void OpenSettingsMenu(){
diff --git a/Resources/Scripts/notification.js b/Resources/Scripts/notification.js
index 0d40df17..5c662066 100644
--- a/Resources/Scripts/notification.js
+++ b/Resources/Scripts/notification.js
@@ -114,7 +114,7 @@
     var account = embedded[0].getElementsByClassName("account-link");
     if (account.length === 0)return;
     
-    $TD.setNotificationTweetEmbedded(account[0].getAttribute("href")+"/status/"+tweetId);
+    $TD.setNotificationQuotedTweet(account[0].getAttribute("href")+"/status/"+tweetId);
   })();
   
   //