From 6c31f2ad60d83c3238252c486c3a7ec5fc856590 Mon Sep 17 00:00:00 2001 From: Simon Howe Date: Thu, 3 Nov 2016 22:15:51 +0100 Subject: [PATCH] Fixes the terminal spamming POST requests on resize Forgot to debounce the initial implementation --- client/app/scripts/components/terminal.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/app/scripts/components/terminal.js b/client/app/scripts/components/terminal.js index bb27f696d..e50abf937 100644 --- a/client/app/scripts/components/terminal.js +++ b/client/app/scripts/components/terminal.js @@ -4,6 +4,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { connect } from 'react-redux'; import classNames from 'classnames'; +import _ from 'lodash'; import { clickCloseTerminal } from '../actions/app-actions'; import { getNeutralColor } from '../utils/color-utils'; @@ -203,7 +204,7 @@ class Terminal extends React.Component { const {characterWidth, characterHeight} = terminalCellSize(this.term.element); - window.addEventListener('resize', this.handleResize); + window.addEventListener('resize', _.debounce(this.handleResize, 500)); this.resizeTimeout = setTimeout(() => { this.setState({