diff --git a/packages/editor-ui/src/components/BreakpointsObserver.vue b/packages/editor-ui/src/components/BreakpointsObserver.vue index 808dc3917b..b34a54799d 100644 --- a/packages/editor-ui/src/components/BreakpointsObserver.vue +++ b/packages/editor-ui/src/components/BreakpointsObserver.vue @@ -47,7 +47,7 @@ export default mixins(genericHelpers).extend({ }, methods: { onResize() { - this.callDebounced("onResizeEnd", 50); + this.callDebounced("onResizeEnd", { debounceTime: 50 }); }, onResizeEnd() { this.$data.width = window.innerWidth; diff --git a/packages/editor-ui/src/components/ExpressionEdit.vue b/packages/editor-ui/src/components/ExpressionEdit.vue index 9b74c381e7..531874e4b8 100644 --- a/packages/editor-ui/src/components/ExpressionEdit.vue +++ b/packages/editor-ui/src/components/ExpressionEdit.vue @@ -80,7 +80,7 @@ export default mixins( this.updateDisplayValue(); this.$emit('valueChanged', this.latestValue); } else { - this.callDebounced('updateDisplayValue', 500); + this.callDebounced('updateDisplayValue', { debounceTime: 500 }); } }, diff --git a/packages/editor-ui/src/components/mixins/genericHelpers.ts b/packages/editor-ui/src/components/mixins/genericHelpers.ts index 9b015f0ac3..7362a8ad2d 100644 --- a/packages/editor-ui/src/components/mixins/genericHelpers.ts +++ b/packages/editor-ui/src/components/mixins/genericHelpers.ts @@ -76,13 +76,12 @@ export const genericHelpers = mixins(showMessage).extend({ async callDebounced (...inputParameters: any[]): Promise { // tslint:disable-line:no-any const functionName = inputParameters.shift() as string; - const debounceTime = inputParameters.shift() as number; - const trailing = inputParameters.shift() as boolean; - + const { trailing, debounceTime } = inputParameters.shift(); + // @ts-ignore if (this.debouncedFunctions[functionName] === undefined) { // @ts-ignore - this.debouncedFunctions[functionName] = debounce(this[functionName], debounceTime, trailing ? { trailing: true } : { leading: true } ); + this.debouncedFunctions[functionName] = debounce(this[functionName], debounceTime, trailing ? { trailing } : { leading: true } ); } // @ts-ignore await this.debouncedFunctions[functionName].apply(this, inputParameters); diff --git a/packages/editor-ui/src/views/NodeView.vue b/packages/editor-ui/src/views/NodeView.vue index 15be05eac3..0527c47770 100644 --- a/packages/editor-ui/src/views/NodeView.vue +++ b/packages/editor-ui/src/views/NodeView.vue @@ -683,13 +683,13 @@ export default mixins( } if (e.key === 'd') { - this.callDebounced('deactivateSelectedNode', 350); + this.callDebounced('deactivateSelectedNode', { debounceTime: 350 }); } else if (e.key === 'Delete' || e.key === 'Backspace') { e.stopPropagation(); e.preventDefault(); - this.callDebounced('deleteSelectedNodes', 500); + this.callDebounced('deleteSelectedNodes', { debounceTime: 500 }); } else if (e.key === 'Tab') { this.createNodeActive = !this.createNodeActive && !this.isReadOnly; @@ -701,7 +701,7 @@ export default mixins( } else if (e.key === 'F2' && !this.isReadOnly) { const lastSelectedNode = this.lastSelectedNode; if (lastSelectedNode !== null) { - this.callDebounced('renameNodePrompt', 1500, lastSelectedNode.name); + this.callDebounced('renameNodePrompt', { debounceTime: 1500 }, lastSelectedNode.name); } } else if ((e.key === '=' || e.key === '+') && !this.isCtrlKeyPressed(e)) { this.zoomIn(); @@ -716,15 +716,15 @@ export default mixins( e.stopPropagation(); e.preventDefault(); - this.callDebounced('selectAllNodes', 1000); + this.callDebounced('selectAllNodes', { debounceTime: 1000 }); } else if ((e.key === 'c') && (this.isCtrlKeyPressed(e) === true)) { - this.callDebounced('copySelectedNodes', 1000); + this.callDebounced('copySelectedNodes', { debounceTime: 1000 }); } else if ((e.key === 'x') && (this.isCtrlKeyPressed(e) === true)) { // Cut nodes e.stopPropagation(); e.preventDefault(); - this.callDebounced('cutSelectedNodes', 1000); + this.callDebounced('cutSelectedNodes', { debounceTime: 1000 }); } else if (e.key === 'o' && this.isCtrlKeyPressed(e) === true) { // Open workflow dialog e.stopPropagation(); @@ -755,7 +755,7 @@ export default mixins( return; } - this.callDebounced('onSaveKeyboardShortcut', 1000); + this.callDebounced('onSaveKeyboardShortcut', { debounceTime: 1000 }); } else if (e.key === 'Enter') { // Activate the last selected node const lastSelectedNode = this.lastSelectedNode; @@ -768,7 +768,7 @@ export default mixins( e.stopPropagation(); e.preventDefault(); - this.callDebounced('selectDownstreamNodes', 1000); + this.callDebounced('selectDownstreamNodes', { debounceTime: 1000 }); } else if (e.key === 'ArrowRight') { // Set child node active const lastSelectedNode = this.lastSelectedNode; @@ -782,13 +782,13 @@ export default mixins( return; } - this.callDebounced('nodeSelectedByName', 100, connections.main[0][0].node, false, true); + this.callDebounced('nodeSelectedByName', { debounceTime: 100 }, connections.main[0][0].node, false, true); } else if (e.key === 'ArrowLeft' && e.shiftKey === true) { // Select all downstream nodes e.stopPropagation(); e.preventDefault(); - this.callDebounced('selectUpstreamNodes', 1000); + this.callDebounced('selectUpstreamNodes', { debounceTime: 1000 }); } else if (e.key === 'ArrowLeft') { // Set parent node active const lastSelectedNode = this.lastSelectedNode; @@ -808,7 +808,7 @@ export default mixins( return; } - this.callDebounced('nodeSelectedByName', 100, connections.main[0][0].node, false, true); + this.callDebounced('nodeSelectedByName', { debounceTime: 100 }, connections.main[0][0].node, false, true); } else if (['ArrowUp', 'ArrowDown'].includes(e.key)) { // Set sibling node as active @@ -866,7 +866,7 @@ export default mixins( } if (nextSelectNode !== null) { - this.callDebounced('nodeSelectedByName', 100, nextSelectNode, false, true); + this.callDebounced('nodeSelectedByName', { debounceTime: 100 }, nextSelectNode, false, true); } } }, diff --git a/packages/editor-ui/src/views/TemplatesSearchView.vue b/packages/editor-ui/src/views/TemplatesSearchView.vue index 57fb46da6e..6070dcad54 100644 --- a/packages/editor-ui/src/views/TemplatesSearchView.vue +++ b/packages/editor-ui/src/views/TemplatesSearchView.vue @@ -208,7 +208,7 @@ export default mixins(genericHelpers).extend({ this.loadingWorkflows = true; this.loadingCollections = true; this.search = search; - this.callDebounced('updateSearch', 500, true); + this.callDebounced('updateSearch', { debounceTime: 500, trailing: true }); if (search.length === 0) { this.trackSearch();