1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-15 15:15:46 +02:00

Add a global function (including one for plugins) to reload columns

This commit is contained in:
chylex 2017-11-09 18:15:58 +01:00
parent 13646d9c90
commit f1b16eab9a
5 changed files with 22 additions and 10 deletions

View File

@ -350,6 +350,10 @@ public void TriggerTweetScreenshot(){
browser.TriggerTweetScreenshot();
}
public void ReloadColumns(){
browser.ReloadColumns();
}
public void ApplyROT13(){
browser.ApplyROT13();
}

View File

@ -231,6 +231,10 @@ public void TriggerTweetScreenshot(){
browser.ExecuteScriptAsync("TDGF_triggerScreenshot()");
}
public void ReloadColumns(){
browser.ExecuteScriptAsync("TDGF_reloadColumns()");
}
public void ApplyROT13(){
browser.ExecuteScriptAsync("TDGF_applyROT13()");
}

View File

@ -1,8 +1,4 @@
enabled(){
this.reloadColumns = () => {
Object.values(TD.controller.columnManager.getAll()).forEach(column => column.reloadTweets());
};
// styles
this.css = window.TDPF_createCustomStyle(this);
@ -10,17 +6,17 @@ enabled(){
// utility functions
var hasPoll = function(tweet){
const hasPoll = function(tweet){
return tweet.hasPoll && tweet.hasPoll();
};
var renderTweetPoll = function(tweet){
const renderTweetPoll = function(tweet){
return `<div class='td-timeline-poll'>${TD.ui.template.render("status/poll", $.extend({}, tweet, {
chirp: tweet
}))}</div>`;
};
var renderPollHook = function(tweet, html){
const renderPollHook = function(tweet, html){
let ele = null;
if (hasPoll(tweet)){
@ -67,7 +63,7 @@ enabled(){
};
this.prevRenderFuncs = funcs;
this.reloadColumns();
window.TDPF_reloadColumns();
}
disabled(){
@ -76,5 +72,5 @@ disabled(){
TD.components.TweetDetailView.prototype._renderChirp = this.prevRenderFuncs.TweetDetailView;
this.css.remove();
this.reloadColumns();
}
window.TDPF_reloadColumns();
}

View File

@ -1116,6 +1116,13 @@
});
});
//
// Block: Setup global function to refresh all columns.
//
window.TDGF_reloadColumns = function(){
Object.values(TD.controller.columnManager.getAll()).forEach(column => column.reloadTweets());
};
//
// Block: Allow applying ROT13 to input selection.
//

View File

@ -107,5 +107,6 @@
// Block: Setup bridges to global functions.
//
window.TDPF_playVideo = window.TDGF_playVideo;
window.TDPF_reloadColumns = window.TDGF_reloadColumns;
window.TDPF_prioritizeNewestEvent = window.TDGF_prioritizeNewestEvent;
})();