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 => {
|
notification.FinishCurrentNotification();
|
||||||
JavascriptResponse response = task.Result;
|
browser.ExecuteScriptAsync("window.TDGF_showTweetDetail", columnKey, chirpId);
|
||||||
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnTweetScreenshotReady(string html, int width, int height){
|
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);
|
base.OnBeforeContextMenu(browserControl, browser, frame, parameters, model);
|
||||||
|
|
||||||
if (enableCustomMenu){
|
if (enableCustomMenu){
|
||||||
model.AddItem(MenuViewDetail, "View detail");
|
if (!string.IsNullOrEmpty(form.CurrentChirpId)){
|
||||||
|
model.AddItem(MenuViewDetail, "View detail");
|
||||||
|
}
|
||||||
|
|
||||||
model.AddItem(MenuSkipTweet, "Skip tweet");
|
model.AddItem(MenuSkipTweet, "Skip tweet");
|
||||||
model.AddCheckItem(MenuFreeze, "Freeze");
|
model.AddCheckItem(MenuFreeze, "Freeze");
|
||||||
model.SetChecked(MenuFreeze, form.FreezeTimer);
|
model.SetChecked(MenuFreeze, form.FreezeTimer);
|
||||||
@ -69,7 +72,7 @@ public override bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser b
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case MenuViewDetail:
|
case MenuViewDetail:
|
||||||
form.InvokeSafe(() => form.ShowTweetDetail());
|
form.InvokeSafe(form.ShowTweetDetail);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case MenuCopyTweetUrl:
|
case MenuCopyTweetUrl:
|
||||||
|
@ -82,6 +82,7 @@ public bool CanResizeWindow{
|
|||||||
private TweetNotification currentNotification;
|
private TweetNotification currentNotification;
|
||||||
private int pauseCounter;
|
private int pauseCounter;
|
||||||
|
|
||||||
|
public string CurrentChirpId => currentNotification?.ChirpId;
|
||||||
public string CurrentTweetUrl => currentNotification?.TweetUrl;
|
public string CurrentTweetUrl => currentNotification?.TweetUrl;
|
||||||
public string CurrentQuoteUrl => currentNotification?.QuoteUrl;
|
public string CurrentQuoteUrl => currentNotification?.QuoteUrl;
|
||||||
public bool IsPaused => pauseCounter > 0;
|
public bool IsPaused => pauseCounter > 0;
|
||||||
|
@ -196,10 +196,12 @@
|
|||||||
|
|
||||||
let source = tweet.getRelatedTweet();
|
let source = tweet.getRelatedTweet();
|
||||||
let duration = source ? source.text.length+(source.quotedTweet ? source.quotedTweet.text.length : 0) : tweet.text.length;
|
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 tweetUrl = source ? source.getChirpURL() : "";
|
||||||
let quoteUrl = source && source.quotedTweet ? source.quotedTweet.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()){
|
if (column.model.getHasSound()){
|
||||||
@ -211,19 +213,36 @@
|
|||||||
//
|
//
|
||||||
// Function: Shows tweet detail, used in notification context menu.
|
// Function: Shows tweet detail, used in notification context menu.
|
||||||
//
|
//
|
||||||
window.TDGF_showTweetDetail = function(columnKey, tweetId){
|
(function(){
|
||||||
let column = TD.controller.columnManager.get(columnKey);
|
var showTweetDetailInternal = function(column, chirp){
|
||||||
return 1 if !column; // column no longer exists
|
TD.ui.updates.showDetailView(column, chirp, column.findChirp(chirp) || chirp);
|
||||||
|
TD.controller.columnManager.showColumn(column.model.privateState.key);
|
||||||
|
|
||||||
|
$(document).trigger("uiGridClearSelection");
|
||||||
|
};
|
||||||
|
|
||||||
let chirp = column.findMostInterestingChirp(tweetId);
|
window.TDGF_showTweetDetail = function(columnKey, chirpId){
|
||||||
return 2 if !chirp; // TODO figure out -- tweet is no longer in cache
|
let column = TD.controller.columnManager.get(columnKey);
|
||||||
|
|
||||||
TD.ui.updates.showDetailView(column, chirp, column.findChirp(chirp));
|
if (!column){
|
||||||
TD.controller.columnManager.showColumn(columnKey);
|
$TD.alert("error", "The column which contained the tweet no longer exists.");
|
||||||
|
return;
|
||||||
$(document).trigger("uiGridClearSelection");
|
}
|
||||||
return 0;
|
|
||||||
};
|
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.
|
// Function: Retrieves the tags to be put into <head> for notification HTML code.
|
||||||
|
Loading…
Reference in New Issue
Block a user