mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-22 09:15:48 +02:00
Finish implementing 'View detail' context menu option in notifications
Closes #152
This commit is contained in:
parent
59c9801437
commit
6357708533
Core
Resources/Scripts
@ -552,19 +552,8 @@ public void ShowTweetDetail(string columnKey, string chirpId){
|
||||
}
|
||||
}
|
||||
|
||||
browser.EvaluateScriptAsync("window.TDGF_showTweetDetail", columnKey, chirpId).ContinueWith(task => {
|
||||
JavascriptResponse response = task.Result;
|
||||
|
||||
if (response.Success){
|
||||
switch(response.Result as int? ?? -1){
|
||||
case 0: this.InvokeAsyncSafe(notification.FinishCurrentNotification); return;
|
||||
case 1: FormMessage.Error("View Tweet Detail", "The column which contained the tweet no longer exists.", FormMessage.OK); return;
|
||||
case 2: FormMessage.Error("View Tweet Detail", "The tweet has been unloaded.", FormMessage.OK); return; // TODO load the tweet
|
||||
}
|
||||
}
|
||||
|
||||
FormMessage.Error("View Tweet Detail", "An unknown error occurred when trying to view tweet detail.", FormMessage.OK);
|
||||
});
|
||||
notification.FinishCurrentNotification();
|
||||
browser.ExecuteScriptAsync("window.TDGF_showTweetDetail", columnKey, chirpId);
|
||||
}
|
||||
|
||||
public void OnTweetScreenshotReady(string html, int width, int height){
|
||||
|
@ -29,7 +29,10 @@ public override void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser br
|
||||
base.OnBeforeContextMenu(browserControl, browser, frame, parameters, model);
|
||||
|
||||
if (enableCustomMenu){
|
||||
if (!string.IsNullOrEmpty(form.CurrentChirpId)){
|
||||
model.AddItem(MenuViewDetail, "View detail");
|
||||
}
|
||||
|
||||
model.AddItem(MenuSkipTweet, "Skip tweet");
|
||||
model.AddCheckItem(MenuFreeze, "Freeze");
|
||||
model.SetChecked(MenuFreeze, form.FreezeTimer);
|
||||
@ -69,7 +72,7 @@ public override bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser b
|
||||
return true;
|
||||
|
||||
case MenuViewDetail:
|
||||
form.InvokeSafe(() => form.ShowTweetDetail());
|
||||
form.InvokeSafe(form.ShowTweetDetail);
|
||||
return true;
|
||||
|
||||
case MenuCopyTweetUrl:
|
||||
|
@ -82,6 +82,7 @@ public bool CanResizeWindow{
|
||||
private TweetNotification currentNotification;
|
||||
private int pauseCounter;
|
||||
|
||||
public string CurrentChirpId => currentNotification?.ChirpId;
|
||||
public string CurrentTweetUrl => currentNotification?.TweetUrl;
|
||||
public string CurrentQuoteUrl => currentNotification?.QuoteUrl;
|
||||
public bool IsPaused => pauseCounter > 0;
|
||||
|
@ -196,10 +196,12 @@
|
||||
|
||||
let source = tweet.getRelatedTweet();
|
||||
let duration = source ? source.text.length+(source.quotedTweet ? source.quotedTweet.text.length : 0) : tweet.text.length;
|
||||
|
||||
let chirpId = source ? source.id : "";
|
||||
let tweetUrl = source ? source.getChirpURL() : "";
|
||||
let quoteUrl = source && source.quotedTweet ? source.quotedTweet.getChirpURL() : "";
|
||||
|
||||
$TD.onTweetPopup(column.model.privateState.key, tweet.id, columnTypes[column.getColumnType()] || "", html.html(), duration, tweetUrl, quoteUrl);
|
||||
$TD.onTweetPopup(column.model.privateState.key, chirpId, columnTypes[column.getColumnType()] || "", html.html(), duration, tweetUrl, quoteUrl);
|
||||
}
|
||||
|
||||
if (column.model.getHasSound()){
|
||||
@ -211,20 +213,37 @@
|
||||
//
|
||||
// Function: Shows tweet detail, used in notification context menu.
|
||||
//
|
||||
window.TDGF_showTweetDetail = function(columnKey, tweetId){
|
||||
let column = TD.controller.columnManager.get(columnKey);
|
||||
return 1 if !column; // column no longer exists
|
||||
|
||||
let chirp = column.findMostInterestingChirp(tweetId);
|
||||
return 2 if !chirp; // TODO figure out -- tweet is no longer in cache
|
||||
|
||||
TD.ui.updates.showDetailView(column, chirp, column.findChirp(chirp));
|
||||
TD.controller.columnManager.showColumn(columnKey);
|
||||
(function(){
|
||||
var showTweetDetailInternal = function(column, chirp){
|
||||
TD.ui.updates.showDetailView(column, chirp, column.findChirp(chirp) || chirp);
|
||||
TD.controller.columnManager.showColumn(column.model.privateState.key);
|
||||
|
||||
$(document).trigger("uiGridClearSelection");
|
||||
return 0;
|
||||
};
|
||||
|
||||
window.TDGF_showTweetDetail = function(columnKey, chirpId){
|
||||
let column = TD.controller.columnManager.get(columnKey);
|
||||
|
||||
if (!column){
|
||||
$TD.alert("error", "The column which contained the tweet no longer exists.");
|
||||
return;
|
||||
}
|
||||
|
||||
let chirp = column.findMostInterestingChirp(chirpId);
|
||||
|
||||
if (chirp){
|
||||
showTweetDetailInternal(column, chirp);
|
||||
}
|
||||
else{
|
||||
TD.controller.clients.getPreferredClient().show(chirpId, function(chirp){
|
||||
showTweetDetailInternal(column, chirp);
|
||||
}, function(){
|
||||
$TD.alert("error", "Could not retrieve the requested tweet.");
|
||||
});
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
//
|
||||
// Function: Retrieves the tags to be put into <head> for notification HTML code.
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user