Merge pull request #464 from glowing-bear/hotfix-async-plugins
Rerun async plugins after buffer switch
This commit is contained in:
commit
39b22da985
1 changed files with 11 additions and 6 deletions
|
@ -33,17 +33,22 @@ weechat.directive('plugin', ['$rootScope', function($rootScope) {
|
|||
* content is shown.
|
||||
*/
|
||||
|
||||
// If the plugin is asynchronous / lazy, execute it now and store
|
||||
// the result. This ensures that the callback is executed only once
|
||||
var embed = document.querySelector(".embed_" + $scope.plugin.$$hashKey);
|
||||
|
||||
// If the plugin is asynchronous / lazy, execute it now and let it insert itself
|
||||
// TODO store the result between channel switches
|
||||
if ($scope.plugin.content instanceof Function){
|
||||
$scope.plugin.content = $scope.plugin.content();
|
||||
// Don't rerun if the result is already there
|
||||
if (embed.innerHTML === "") {
|
||||
$scope.plugin.content();
|
||||
}
|
||||
} else {
|
||||
$scope.displayedContent = $scope.plugin.content;
|
||||
}
|
||||
$scope.plugin.visible = true;
|
||||
|
||||
// Scroll embed content into view
|
||||
var scroll = function() {
|
||||
var embed = document.querySelector(".embed_" + $scope.plugin.$$hashKey);
|
||||
if (embed && embed.scrollIntoViewIfNeeded !== undefined) {
|
||||
embed.scrollIntoViewIfNeeded();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue