Welcome to mirror list, hosted at ThFree Co, Russian Federation.

setup.js « editor « modules « stores « ide « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c5a613c6baa22b460168e679a8b4fabe3f632387 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import eventHub from '~/ide/eventhub';
import { commitActionTypes } from '~/ide/constants';

const removeUnusedFileEditors = store => {
  Object.keys(store.state.editor.fileEditors)
    .filter(path => !store.state.entries[path])
    .forEach(path => store.dispatch('editor/removeFileEditor', path));
};

export const setupFileEditorsSync = store => {
  eventHub.$on('ide.files.change', ({ type, ...payload } = {}) => {
    if (type === commitActionTypes.move) {
      store.dispatch('editor/renameFileEditor', payload);
    } else {
      // The files have changed, but the specific change is not known.
      removeUnusedFileEditors(store);
    }
  });
};