diff --git a/Core/Bridge/TweetDeckBridge.cs b/Core/Bridge/TweetDeckBridge.cs index 30d6a52c..d81d1a7f 100644 --- a/Core/Bridge/TweetDeckBridge.cs +++ b/Core/Bridge/TweetDeckBridge.cs @@ -49,18 +49,14 @@ public void SetLastHighlightedTweet(string link, string quotedLink){ }); } - public void SetNotificationQuotedTweet(string link){ - notification.InvokeAsyncSafe(() => notification.CurrentQuotedTweetUrl = link); - } - public void OpenContextMenu(){ form.InvokeAsyncSafe(form.OpenContextMenu); } - public void OnTweetPopup(string columnName, string tweetHtml, string tweetUrl, int tweetCharacters){ + public void OnTweetPopup(string columnName, string tweetHtml, int tweetCharacters, string tweetUrl, string quoteUrl){ notification.InvokeAsyncSafe(() => { form.OnTweetNotification(); - notification.ShowNotification(new TweetNotification(columnName, tweetHtml, tweetUrl, tweetCharacters)); + notification.ShowNotification(new TweetNotification(columnName, tweetHtml, tweetCharacters, tweetUrl, quoteUrl)); }); } diff --git a/Core/Handling/ContextMenuNotification.cs b/Core/Handling/ContextMenuNotification.cs index 42d2fb66..d9f287f9 100644 --- a/Core/Handling/ContextMenuNotification.cs +++ b/Core/Handling/ContextMenuNotification.cs @@ -33,10 +33,10 @@ public override void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser br model.SetChecked((CefMenuCommand)MenuFreeze, form.FreezeTimer); model.AddSeparator(); - if (!string.IsNullOrEmpty(form.CurrentUrl)){ + if (!string.IsNullOrEmpty(form.CurrentTweetUrl)){ model.AddItem((CefMenuCommand)MenuCopyTweetUrl, "Copy tweet address"); - if (!string.IsNullOrEmpty(form.CurrentQuotedTweetUrl)){ + if (!string.IsNullOrEmpty(form.CurrentQuoteUrl)){ model.AddItem((CefMenuCommand)MenuCopyQuotedTweetUrl, "Copy quoted tweet address"); } @@ -68,11 +68,11 @@ public override bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser b return true; case MenuCopyTweetUrl: - SetClipboardText(form.CurrentUrl); + SetClipboardText(form.CurrentTweetUrl); return true; case MenuCopyQuotedTweetUrl: - SetClipboardText(form.CurrentQuotedTweetUrl); + SetClipboardText(form.CurrentQuoteUrl); return true; } diff --git a/Core/Notification/FormNotificationBase.cs b/Core/Notification/FormNotificationBase.cs index 49a0536f..718e926e 100644 --- a/Core/Notification/FormNotificationBase.cs +++ b/Core/Notification/FormNotificationBase.cs @@ -90,8 +90,8 @@ 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 string CurrentTweetUrl { get; private set; } + public string CurrentQuoteUrl { get; private set; } public event EventHandler Initialized; @@ -179,8 +179,8 @@ protected virtual string GetTweetHTML(TweetNotification tweet){ } protected virtual void LoadTweet(TweetNotification tweet){ - CurrentUrl = tweet.Url; - CurrentQuotedTweetUrl = string.Empty; // load from JS + CurrentTweetUrl = tweet.TweetUrl; + CurrentQuoteUrl = tweet.QuoteUrl; currentColumn = tweet.Column; resourceHandler.SetHTML(GetTweetHTML(tweet)); diff --git a/Core/Notification/Screenshot/TweetScreenshotManager.cs b/Core/Notification/Screenshot/TweetScreenshotManager.cs index ef87de2d..553c4100 100644 --- a/Core/Notification/Screenshot/TweetScreenshotManager.cs +++ b/Core/Notification/Screenshot/TweetScreenshotManager.cs @@ -44,7 +44,7 @@ public void Trigger(string html, int width, int height){ CanMoveWindow = () => false }; - screenshot.LoadNotificationForScreenshot(new TweetNotification(string.Empty, html, string.Empty, 0), width, height); + screenshot.LoadNotificationForScreenshot(new TweetNotification(string.Empty, html, 0, string.Empty, string.Empty), width, height); screenshot.Show(); timeout.Start(); } diff --git a/Core/Notification/TweetNotification.cs b/Core/Notification/TweetNotification.cs index 21f27aed..ec5481a5 100644 --- a/Core/Notification/TweetNotification.cs +++ b/Core/Notification/TweetNotification.cs @@ -35,7 +35,7 @@ public static TweetNotification ExampleTweet{ #endif } - return new TweetNotification("Home", ExampleTweetHTML, "", 95, true); + return new TweetNotification("Home", ExampleTweetHTML, 95, string.Empty, string.Empty, true); } } @@ -57,24 +57,32 @@ public string Column{ } } - public string Url{ + public string TweetUrl{ get{ - return url; + return tweetUrl; + } + } + + public string QuoteUrl{ + get{ + return quoteUrl; } } private readonly string column; private readonly string html; - private readonly string url; private readonly int characters; + private readonly string tweetUrl; + private readonly string quoteUrl; private readonly bool isExample; - public TweetNotification(string column, string html, string url, int characters) : this(column, html, url, characters, false){} + public TweetNotification(string column, string html, int characters, string tweetUrl, string quoteUrl) : this(column, html, characters, tweetUrl, quoteUrl, false){} - private TweetNotification(string column, string html, string url, int characters, bool isExample){ + private TweetNotification(string column, string html, int characters, string tweetUrl, string quoteUrl, bool isExample){ this.column = column; this.html = html; - this.url = url; + this.tweetUrl = tweetUrl; + this.quoteUrl = quoteUrl; this.characters = characters; this.isExample = isExample; } diff --git a/Resources/Scripts/code.js b/Resources/Scripts/code.js index 4a9133d2..38ef79ac 100644 --- a/Resources/Scripts/code.js +++ b/Resources/Scripts/code.js @@ -96,10 +96,12 @@ html.find(".js-media").last().remove(); // and quoted tweets still show media previews, nice nice html.find(".js-quote-detail").removeClass("is-actionable"); - let url = html.find("time").first().children("a").first().attr("href") || ""; - let length = tweet.text.length+(tweet.quotedTweet ? tweet.quotedTweet.text.length : 0); + let source = tweet.getRelatedTweet(); + let duration = source ? source.text.length+(source.quotedTweet ? source.quotedTweet.text.length : 0) : tweet.text.length; + let tweetUrl = source ? source.getChirpURL() : ""; + let quoteUrl = source && source.quotedTweet ? source.quotedTweet.getChirpURL() : ""; - $TD.onTweetPopup(columnTypes[column.getColumnType()] || "", html.html(), url, length); + $TD.onTweetPopup(columnTypes[column.getColumnType()] || "", html.html(), duration, tweetUrl, quoteUrl); } if (column.model.getHasSound()){ diff --git a/Resources/Scripts/notification.js b/Resources/Scripts/notification.js index 15c15f05..677a1ed3 100644 --- a/Resources/Scripts/notification.js +++ b/Resources/Scripts/notification.js @@ -101,22 +101,6 @@ }); })(); - // - // Block: Setup embedded tweet address for context menu. - // - (function(){ - var embedded = document.getElementsByClassName("quoted-tweet"); - if (embedded.length === 0)return; - - var tweetId = embedded[0].getAttribute("data-tweet-id"); - if (!tweetId)return; - - var account = embedded[0].getElementsByClassName("account-link"); - if (account.length === 0)return; - - $TD.setNotificationQuotedTweet(account[0].getAttribute("href")+"/status/"+tweetId); - })(); - // // Block: Setup a skip button. //