diff options
Diffstat (limited to 'app/assets/javascripts/ide/stores/plugins/terminal_sync.js')
-rw-r--r-- | app/assets/javascripts/ide/stores/plugins/terminal_sync.js | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/app/assets/javascripts/ide/stores/plugins/terminal_sync.js b/app/assets/javascripts/ide/stores/plugins/terminal_sync.js index c60bba4293a..d925a5f7567 100644 --- a/app/assets/javascripts/ide/stores/plugins/terminal_sync.js +++ b/app/assets/javascripts/ide/stores/plugins/terminal_sync.js @@ -1,5 +1,6 @@ import { debounce } from 'lodash'; import eventHub from '~/ide/eventhub'; +import { commitActionTypes } from '~/ide/constants'; import terminalSyncModule from '../modules/terminal_sync'; import { isEndingStatus, isRunningStatus } from '../modules/terminal/utils'; @@ -12,23 +13,32 @@ const UPLOAD_DEBOUNCE = 200; * - Listens for file change event to control upload. */ export default function createMirrorPlugin() { - return store => { + return (store) => { store.registerModule('terminalSync', terminalSyncModule()); const upload = debounce(() => { store.dispatch(`terminalSync/upload`); }, UPLOAD_DEBOUNCE); + const onFilesChange = (payload) => { + // Do nothing on a file update since we only want to trigger manually on "save". + if (payload?.type === commitActionTypes.update) { + return; + } + + upload(); + }; + const stop = () => { store.dispatch(`terminalSync/stop`); - eventHub.$off('ide.files.change', upload); + eventHub.$off('ide.files.change', onFilesChange); }; const start = () => { store .dispatch(`terminalSync/start`) .then(() => { - eventHub.$on('ide.files.change', upload); + eventHub.$on('ide.files.change', onFilesChange); }) .catch(() => { // error is handled in store @@ -36,8 +46,8 @@ export default function createMirrorPlugin() { }; store.watch( - x => x.terminal && x.terminal.session && x.terminal.session.status, - val => { + (x) => x.terminal && x.terminal.session && x.terminal.session.status, + (val) => { if (isRunningStatus(val)) { start(); } else if (isEndingStatus(val)) { |