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.
|
* content is shown.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// If the plugin is asynchronous / lazy, execute it now and store
|
var embed = document.querySelector(".embed_" + $scope.plugin.$$hashKey);
|
||||||
// the result. This ensures that the callback is executed only once
|
|
||||||
if ($scope.plugin.content instanceof Function) {
|
// If the plugin is asynchronous / lazy, execute it now and let it insert itself
|
||||||
$scope.plugin.content = $scope.plugin.content();
|
// TODO store the result between channel switches
|
||||||
|
if ($scope.plugin.content instanceof Function){
|
||||||
|
// Don't rerun if the result is already there
|
||||||
|
if (embed.innerHTML === "") {
|
||||||
|
$scope.plugin.content();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$scope.displayedContent = $scope.plugin.content;
|
||||||
}
|
}
|
||||||
$scope.displayedContent = $scope.plugin.content;
|
|
||||||
$scope.plugin.visible = true;
|
$scope.plugin.visible = true;
|
||||||
|
|
||||||
// Scroll embed content into view
|
// Scroll embed content into view
|
||||||
var scroll = function() {
|
var scroll = function() {
|
||||||
var embed = document.querySelector(".embed_" + $scope.plugin.$$hashKey);
|
|
||||||
if (embed && embed.scrollIntoViewIfNeeded !== undefined) {
|
if (embed && embed.scrollIntoViewIfNeeded !== undefined) {
|
||||||
embed.scrollIntoViewIfNeeded();
|
embed.scrollIntoViewIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue