Commit 299aad3d authored by Phil Hughes's avatar Phil Hughes

fixed staged content not updating

parent 26901470
...@@ -29,7 +29,13 @@ export default { ...@@ -29,7 +29,13 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(['discardFileChanges', 'updateViewer', 'openPendingTab']), ...mapActions([
'discardFileChanges',
'updateViewer',
'openPendingTab',
'unstageChange',
'stageChange',
]),
openFileInEditor() { openFileInEditor() {
return this.openPendingTab({ return this.openPendingTab({
file: this.file, file: this.file,
......
...@@ -69,7 +69,13 @@ export default { ...@@ -69,7 +69,13 @@ export default {
path: this.file.path, path: this.file.path,
baseSha: this.currentMergeRequest ? this.currentMergeRequest.baseCommitSha : '', baseSha: this.currentMergeRequest ? this.currentMergeRequest.baseCommitSha : '',
}) })
.then(() => this.updateViewer(this.file.pending ? 'diff' : this.viewer)) .then(() => {
const viewerPromise = this.delayViewerUpdated
? this.updateViewer('editor')
: Promise.resolve();
return viewerPromise;
})
.then(() => { .then(() => {
this.updateDelayViewerUpdated(false); this.updateDelayViewerUpdated(false);
this.createEditorInstance(); this.createEditorInstance();
......
...@@ -34,10 +34,12 @@ export default class Model { ...@@ -34,10 +34,12 @@ export default class Model {
this.events = new Map(); this.events = new Map();
this.updateContent = this.updateContent.bind(this); this.updateContent = this.updateContent.bind(this);
this.updateNewContent = this.updateNewContent.bind(this);
this.dispose = this.dispose.bind(this); this.dispose = this.dispose.bind(this);
eventHub.$on(`editor.update.model.dispose.${this.file.key}`, this.dispose); eventHub.$on(`editor.update.model.dispose.${this.file.key}`, this.dispose);
eventHub.$on(`editor.update.model.content.${this.file.key}`, this.updateContent); eventHub.$on(`editor.update.model.content.${this.file.key}`, this.updateContent);
eventHub.$on(`editor.update.model.new.content.${this.file.key}`, this.updateNewContent);
} }
get url() { get url() {
...@@ -87,11 +89,16 @@ export default class Model { ...@@ -87,11 +89,16 @@ export default class Model {
} }
} }
updateNewContent(content) {
this.getModel().setValue(content);
}
dispose() { dispose() {
this.disposable.dispose(); this.disposable.dispose();
this.events.clear(); this.events.clear();
eventHub.$off(`editor.update.model.dispose.${this.file.key}`, this.dispose); eventHub.$off(`editor.update.model.dispose.${this.file.key}`, this.dispose);
eventHub.$off(`editor.update.model.content.${this.file.key}`, this.updateContent); eventHub.$off(`editor.update.model.content.${this.file.key}`, this.updateContent);
eventHub.$off(`editor.update.model.new.content.${this.file.key}`, this.updateNewContent);
} }
} }
...@@ -174,10 +174,7 @@ export const stageChange = ({ commit, state }, path) => { ...@@ -174,10 +174,7 @@ export const stageChange = ({ commit, state }, path) => {
commit(types.STAGE_CHANGE, path); commit(types.STAGE_CHANGE, path);
if (stagedFile) { if (stagedFile) {
eventHub.$emit(`editor.update.model.content.staged-${stagedFile.key}`, { eventHub.$emit(`editor.update.model.new.content.staged-${stagedFile.key}`, stagedFile.content);
content: stagedFile.content,
changed: false,
});
} }
}; };
...@@ -186,7 +183,7 @@ export const unstageChange = ({ commit }, path) => { ...@@ -186,7 +183,7 @@ export const unstageChange = ({ commit }, path) => {
}; };
export const openPendingTab = ({ commit, getters, dispatch, state }, { file, keyPrefix }) => { export const openPendingTab = ({ commit, getters, dispatch, state }, { file, keyPrefix }) => {
if (getters.activeFile && getters.activeFile.path === file.path && state.viewer === 'diff') { if (getters.activeFile && getters.activeFile === file && state.viewer === 'diff') {
return false; return false;
} }
......
...@@ -156,7 +156,7 @@ export default { ...@@ -156,7 +156,7 @@ export default {
[types.ADD_PENDING_TAB](state, { file, keyPrefix = 'pending' }) { [types.ADD_PENDING_TAB](state, { file, keyPrefix = 'pending' }) {
const pendingTab = state.openFiles.find(f => f.path === file.path && f.pending); const pendingTab = state.openFiles.find(f => f.path === file.path && f.pending);
let openFiles = state.openFiles.map(f => let openFiles = state.openFiles.map(f =>
Object.assign(f, { active: f.path === file.path, opened: false }), Object.assign(f, { active: f.path === file.path, opened: false, active: false }),
); );
if (!pendingTab) { if (!pendingTab) {
...@@ -168,6 +168,7 @@ export default { ...@@ -168,6 +168,7 @@ export default {
if (f.path === file.path) { if (f.path === file.path) {
return acc.concat({ return acc.concat({
...f, ...f,
content: file.content,
active: true, active: true,
pending: true, pending: true,
opened: true, opened: true,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment