fix(editor): Fix memory leak in Node Detail View by correctly unsubscribing from event buses (#6021)
This commit is contained in:
@@ -37,12 +37,10 @@ export default Vue.extend({
|
||||
if (this.autofocus && this.$refs.input) {
|
||||
this.focus();
|
||||
}
|
||||
|
||||
if (this.eventBus) {
|
||||
this.eventBus.on('focus', () => {
|
||||
this.focus();
|
||||
});
|
||||
}
|
||||
this.eventBus?.on('focus', this.focus);
|
||||
},
|
||||
destroyed() {
|
||||
this.eventBus?.off('focus', this.focus);
|
||||
},
|
||||
methods: {
|
||||
focus() {
|
||||
|
||||
@@ -121,15 +121,8 @@ export default Vue.extend({
|
||||
mounted() {
|
||||
window.addEventListener('keydown', this.onWindowKeydown);
|
||||
|
||||
if (this.eventBus) {
|
||||
this.eventBus.on('close', () => {
|
||||
this.closeDialog();
|
||||
});
|
||||
|
||||
this.eventBus.on('closeAll', () => {
|
||||
this.uiStore.closeAllModals();
|
||||
});
|
||||
}
|
||||
this.eventBus?.on('close', this.closeDialog);
|
||||
this.eventBus?.on('closeAll', this.uiStore.closeAllModals);
|
||||
|
||||
const activeElement = document.activeElement as HTMLElement;
|
||||
if (activeElement) {
|
||||
@@ -137,6 +130,8 @@ export default Vue.extend({
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.eventBus?.off('close', this.closeDialog);
|
||||
this.eventBus?.off('closeAll', this.uiStore.closeAllModals);
|
||||
window.removeEventListener('keydown', this.onWindowKeydown);
|
||||
},
|
||||
computed: {
|
||||
|
||||
@@ -53,12 +53,7 @@ export default Vue.extend({
|
||||
},
|
||||
mounted() {
|
||||
window.addEventListener('keydown', this.onWindowKeydown);
|
||||
|
||||
if (this.eventBus) {
|
||||
this.eventBus.on('close', () => {
|
||||
this.close();
|
||||
});
|
||||
}
|
||||
this.eventBus?.on('close', this.close);
|
||||
|
||||
const activeElement = document.activeElement as HTMLElement;
|
||||
if (activeElement) {
|
||||
@@ -66,6 +61,7 @@ export default Vue.extend({
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.eventBus?.off('close', this.close);
|
||||
window.removeEventListener('keydown', this.onWindowKeydown);
|
||||
},
|
||||
computed: {
|
||||
|
||||
@@ -211,15 +211,10 @@ export default mixins(
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
dataPinningEventBus.on(
|
||||
'data-pinning-discovery',
|
||||
({ isTooltipVisible }: { isTooltipVisible: boolean }) => {
|
||||
this.pinDataDiscoveryTooltipVisible = isTooltipVisible;
|
||||
},
|
||||
);
|
||||
dataPinningEventBus.on('data-pinning-discovery', this.setIsTooltipVisible);
|
||||
},
|
||||
destroyed() {
|
||||
dataPinningEventBus.off('data-pinning-discovery');
|
||||
dataPinningEventBus.off('data-pinning-discovery', this.setIsTooltipVisible);
|
||||
},
|
||||
computed: {
|
||||
...mapStores(useNodeTypesStore, useNDVStore, useUIStore, useWorkflowsStore, useSettingsStore),
|
||||
@@ -480,6 +475,9 @@ export default mixins(
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
setIsTooltipVisible({ isTooltipVisible }: { isTooltipVisible: boolean }) {
|
||||
this.pinDataDiscoveryTooltipVisible = isTooltipVisible;
|
||||
},
|
||||
onKeyDown(e: KeyboardEvent) {
|
||||
if (e.key === 's' && this.isCtrlKeyPressed(e)) {
|
||||
e.stopPropagation();
|
||||
|
||||
@@ -895,18 +895,20 @@ export default mixins(externalHooks, nodeHelpers).extend({
|
||||
onStopExecution() {
|
||||
this.$emit('stopExecution');
|
||||
},
|
||||
openSettings() {
|
||||
this.openPanel = 'settings';
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.populateHiddenIssuesSet();
|
||||
this.setNodeValues();
|
||||
if (this.eventBus) {
|
||||
this.eventBus.on('openSettings', () => {
|
||||
this.openPanel = 'settings';
|
||||
});
|
||||
}
|
||||
this.eventBus?.on('openSettings', this.openSettings);
|
||||
|
||||
this.updateNodeParameterIssues(this.node as INodeUi, this.nodeType);
|
||||
},
|
||||
destroyed() {
|
||||
this.eventBus?.off('openSettings', this.openSettings);
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -585,7 +585,6 @@ export default mixins(externalHooks, genericHelpers, nodeHelpers, pinData).exten
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
pageSizes: [10, 25, 50, 100],
|
||||
eventBus: dataPinningEventBus,
|
||||
|
||||
pinDataDiscoveryTooltipVisible: false,
|
||||
isControlledPinDataTooltip: false,
|
||||
@@ -595,8 +594,8 @@ export default mixins(externalHooks, genericHelpers, nodeHelpers, pinData).exten
|
||||
this.init();
|
||||
|
||||
if (!this.isPaneTypeInput) {
|
||||
this.eventBus.on('data-pinning-error', this.onDataPinningError);
|
||||
this.eventBus.on('data-unpinning', this.onDataUnpinning);
|
||||
dataPinningEventBus.on('data-pinning-error', this.onDataPinningError);
|
||||
dataPinningEventBus.on('data-unpinning', this.onDataUnpinning);
|
||||
|
||||
this.showPinDataDiscoveryTooltip(this.jsonData);
|
||||
}
|
||||
@@ -609,8 +608,8 @@ export default mixins(externalHooks, genericHelpers, nodeHelpers, pinData).exten
|
||||
},
|
||||
destroyed() {
|
||||
this.hidePinDataDiscoveryTooltip();
|
||||
this.eventBus.off('data-pinning-error', this.onDataPinningError);
|
||||
this.eventBus.off('data-unpinning', this.onDataUnpinning);
|
||||
dataPinningEventBus.off('data-pinning-error', this.onDataPinningError);
|
||||
dataPinningEventBus.off('data-unpinning', this.onDataUnpinning);
|
||||
},
|
||||
computed: {
|
||||
...mapStores(useNodeTypesStore, useNDVStore, useWorkflowsStore),
|
||||
@@ -908,7 +907,7 @@ export default mixins(externalHooks, genericHelpers, nodeHelpers, pinData).exten
|
||||
setTimeout(() => {
|
||||
this.isControlledPinDataTooltip = true;
|
||||
this.pinDataDiscoveryTooltipVisible = true;
|
||||
this.eventBus.emit('data-pinning-discovery', { isTooltipVisible: true });
|
||||
dataPinningEventBus.emit('data-pinning-discovery', { isTooltipVisible: true });
|
||||
}, 500); // Wait for NDV to open
|
||||
}
|
||||
},
|
||||
@@ -916,7 +915,7 @@ export default mixins(externalHooks, genericHelpers, nodeHelpers, pinData).exten
|
||||
if (this.pinDataDiscoveryTooltipVisible) {
|
||||
this.isControlledPinDataTooltip = false;
|
||||
this.pinDataDiscoveryTooltipVisible = false;
|
||||
this.eventBus.emit('data-pinning-discovery', { isTooltipVisible: false });
|
||||
dataPinningEventBus.emit('data-pinning-discovery', { isTooltipVisible: false });
|
||||
}
|
||||
},
|
||||
pinDataDiscoveryComplete() {
|
||||
|
||||
@@ -92,15 +92,10 @@ export default mixins(showMessage).extend({
|
||||
deepCopy(defaultMessageEventBusDestinationOptions),
|
||||
this.destination,
|
||||
);
|
||||
this.eventBus.on('destinationWasSaved', () => {
|
||||
const updatedDestination = this.logStreamingStore.getDestination(this.destination.id);
|
||||
if (updatedDestination) {
|
||||
this.nodeParameters = Object.assign(
|
||||
deepCopy(defaultMessageEventBusDestinationOptions),
|
||||
this.destination,
|
||||
);
|
||||
}
|
||||
});
|
||||
this.eventBus?.on('destinationWasSaved', this.onDestinationWasSaved);
|
||||
},
|
||||
destroyed() {
|
||||
this.eventBus?.off('destinationWasSaved', this.onDestinationWasSaved);
|
||||
},
|
||||
computed: {
|
||||
...mapStores(useLogStreamingStore),
|
||||
@@ -124,6 +119,15 @@ export default mixins(showMessage).extend({
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
onDestinationWasSaved() {
|
||||
const updatedDestination = this.logStreamingStore.getDestination(this.destination.id);
|
||||
if (updatedDestination) {
|
||||
this.nodeParameters = Object.assign(
|
||||
deepCopy(defaultMessageEventBusDestinationOptions),
|
||||
this.destination,
|
||||
);
|
||||
}
|
||||
},
|
||||
async onClick(event?: PointerEvent) {
|
||||
if (
|
||||
event &&
|
||||
|
||||
@@ -117,15 +117,13 @@ export default mixins(showMessage).extend({
|
||||
}
|
||||
}
|
||||
|
||||
if (this.eventBus) {
|
||||
this.eventBus.on('focus', () => {
|
||||
this.focusOnInput();
|
||||
this.focusOnTopOption();
|
||||
});
|
||||
}
|
||||
this.eventBus?.on('focus', this.onBusFocus);
|
||||
|
||||
this.tagsStore.fetchAll();
|
||||
},
|
||||
destroyed() {
|
||||
this.eventBus?.off('focus', this.onBusFocus);
|
||||
},
|
||||
computed: {
|
||||
...mapStores(useTagsStore, useUIStore),
|
||||
allTags(): ITag[] {
|
||||
@@ -144,6 +142,10 @@ export default mixins(showMessage).extend({
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
onBusFocus() {
|
||||
this.focusOnInput();
|
||||
this.focusOnTopOption();
|
||||
},
|
||||
filterOptions(filter = '') {
|
||||
this.$data.filter = filter.trim();
|
||||
this.$nextTick(() => this.focusOnTopOption());
|
||||
|
||||
Reference in New Issue
Block a user