fix(editor): Turn off executions list auto-refresh after leaving the page (#8005)

## Summary
Fixes the bug when users leave the executions page but there is still an
ongoing request for executions.

---------

Co-authored-by: Alex Grozav <alex@grozav.com>
This commit is contained in:
Csaba Tuncsik
2023-12-14 11:50:00 +01:00
committed by GitHub
parent b29b4d442b
commit e3c363d72c
5 changed files with 72 additions and 19 deletions

View File

@@ -310,6 +310,7 @@ import { isEmpty } from '@/utils/typesUtils';
import { setPageTitle } from '@/utils/htmlUtils';
import { executionFilterToQueryFilter } from '@/utils/executionUtils';
import { useExternalHooks } from '@/composables/useExternalHooks';
import { useRoute } from 'vue-router';
export default defineComponent({
name: 'ExecutionsList',
@@ -328,11 +329,13 @@ export default defineComponent({
const i18n = useI18n();
const telemetry = useTelemetry();
const externalHooks = useExternalHooks();
const route = useRoute();
return {
i18n,
telemetry,
externalHooks,
route,
...useToast(),
...useMessage(),
};
@@ -346,7 +349,7 @@ export default defineComponent({
allVisibleSelected: false,
allExistingSelected: false,
autoRefresh: this.autoRefreshEnabled,
autoRefresh: false,
autoRefreshTimeout: undefined as undefined | NodeJS.Timer,
filter: {} as ExecutionFilterType,
@@ -361,6 +364,9 @@ export default defineComponent({
workflows: [] as IWorkflowShortResponse[],
};
},
created() {
this.autoRefresh = this.autoRefreshEnabled;
},
mounted() {
setPageTitle(`n8n - ${this.pageTitle}`);
@@ -376,6 +382,7 @@ export default defineComponent({
});
},
beforeUnmount() {
this.autoRefresh = false;
this.stopAutoRefreshInterval();
document.removeEventListener('visibilitychange', this.onDocumentVisibilityChange);
},
@@ -938,7 +945,7 @@ export default defineComponent({
}
},
async startAutoRefreshInterval() {
if (this.autoRefresh) {
if (this.autoRefresh && this.route.name === VIEWS.WORKFLOW_EXECUTIONS) {
await this.loadAutoRefresh();
this.autoRefreshTimeout = setTimeout(() => {
void this.startAutoRefreshInterval();
@@ -946,10 +953,8 @@ export default defineComponent({
}
},
stopAutoRefreshInterval() {
if (this.autoRefreshTimeout) {
clearTimeout(this.autoRefreshTimeout);
this.autoRefreshTimeout = undefined;
}
clearTimeout(this.autoRefreshTimeout);
this.autoRefreshTimeout = undefined;
},
onDocumentVisibilityChange() {
if (document.visibilityState === 'hidden') {