Skip to content

Commit

Permalink
Merge pull request #2036 from sirensolutions/issue-2035
Browse files Browse the repository at this point in the history
BACKPORT the fix for count refresh on tabs
  • Loading branch information
szydan committed Dec 13, 2016
2 parents 60381b3 + 4688f7a commit c1d1188
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/ui/public/kibi/directives/kibi_nav_bar.js
Expand Up @@ -124,9 +124,9 @@ define(function (require) {
});

$scope.$on('$destroy', function () {
kibiNavBarHelper.cancelExecutionInProgress();
removeInitConfigHandler();
removeRelationalPanelHandler();
kibiNavBarHelper.destroy();
removeDashboardGroupChangedHandler();
removeInitConfigHandler();
removeDashboardChangedHandler();
Expand Down
15 changes: 4 additions & 11 deletions src/ui/public/kibi/directives/kibi_nav_bar_helper.js
Expand Up @@ -134,7 +134,7 @@ define(function (require) {
};

$rootScope.$listen(globalState, 'save_with_changes', (diff) => updateCountsOnGlobalStateChange.call(this, diff));
this.removeGetAppStateHandler = $rootScope.$watch(getAppState, (as) => {
$rootScope.$watch(getAppState, (as) => {
if (as) {
this.appState = as;
$rootScope.$listen(this.appState, 'save_with_changes', (diff) => updateCountsOnAppStateChange.call(this, diff));
Expand All @@ -148,7 +148,7 @@ define(function (require) {
// everywhere use this event !!! to be consistent
// make a comment that it was required because not all components can listen to
// esResponse
this.removeAutorefreshHandler = $rootScope.$on('courier:searchRefresh', (event) => {
$rootScope.$on('courier:searchRefresh', (event) => {
const currentDashboard = kibiState._getCurrentDashboardId();
if (!currentDashboard) {
return;
Expand Down Expand Up @@ -218,17 +218,10 @@ define(function (require) {
});
};

KibiNavBarHelper.prototype.destroy = function () {
KibiNavBarHelper.prototype.cancelExecutionInProgress = function () {
if (this.delayExecutionHelper) {
this.delayExecutionHelper.destroy();
this.delayExecutionHelper.cancel();
}
if (this.removeGetAppStateHandler) {
this.removeGetAppStateHandler();
}
if (this.removeAutorefreshHandler) {
this.removeAutorefreshHandler();
}
this.appState = null;
};

KibiNavBarHelper.prototype.getDashboardGroups = function () {
Expand Down
16 changes: 8 additions & 8 deletions src/ui/public/kibi/helpers/__tests__/delay_execution_helper.js
Expand Up @@ -22,9 +22,9 @@ describe('Kibi Components', function () {

describe('DELAY_STRATEGY.RESET_COUNTER_ON_NEW_EVENT', function () {

// e1 destroy X
// e1 cancel X
// |___delay______|
it('1 event and then destroy before "delay" - should not trigger any callback', function (done) {
it('1 event and then cancel before "delay" - should not trigger any callback', function (done) {
var actuallData = [];
var executionCounter = 0;
var helper = new DelayExecutionHelper(
Expand All @@ -38,10 +38,10 @@ describe('Kibi Components', function () {
);

helper.addEventData(['id1']);
// trigger destroy
// trigger cancel
// t < delay
setTimeout(function () {
helper.destroy();
helper.cancel();
}, 50);

setTimeout(function () {
Expand Down Expand Up @@ -169,9 +169,9 @@ describe('Kibi Components', function () {

describe('DELAY_STRATEGY.DO_NOT_RESET_COUNTER_ON_NEW_EVENT', function () {

// e1 destroy X
// e1 cancel X
// |___delay______|
it('1 event and then destroy before "delay" - should not trigger any callback', function (done) {
it('1 event and then cancel before "delay" - should not trigger any callback', function (done) {
var actuallData = [];
var executionCounter = 0;
var helper = new DelayExecutionHelper(
Expand All @@ -185,10 +185,10 @@ describe('Kibi Components', function () {
);

helper.addEventData(['id1']);
// trigger destroy
// trigger cancel
// t < delay
setTimeout(function () {
helper.destroy();
helper.cancel();
}, 50);

setTimeout(function () {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/kibi/helpers/delay_execution_helper.js
Expand Up @@ -38,7 +38,7 @@ define(function (require) {
}, this.delayTime);
};

DelayExecutionHelper.prototype.destroy = function () {
DelayExecutionHelper.prototype.cancel = function () {
this.data = {};
if (this.timeout) {
clearTimeout(this.timeout);
Expand Down

0 comments on commit c1d1188

Please sign in to comment.