未验证 提交 299aad3d 编写于 作者: P Phil Hughes

fixed staged content not updating

上级 26901470
......@@ -29,7 +29,13 @@ export default {
},
},
methods: {
...mapActions(['discardFileChanges', 'updateViewer', 'openPendingTab']),
...mapActions([
'discardFileChanges',
'updateViewer',
'openPendingTab',
'unstageChange',
'stageChange',
]),
openFileInEditor() {
return this.openPendingTab({
file: this.file,
......
......@@ -69,7 +69,13 @@ export default {
path: this.file.path,
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(() => {
this.updateDelayViewerUpdated(false);
this.createEditorInstance();
......
......@@ -34,10 +34,12 @@ export default class Model {
this.events = new Map();
this.updateContent = this.updateContent.bind(this);
this.updateNewContent = this.updateNewContent.bind(this);
this.dispose = this.dispose.bind(this);
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.new.content.${this.file.key}`, this.updateNewContent);
}
get url() {
......@@ -87,11 +89,16 @@ export default class Model {
}
}
updateNewContent(content) {
this.getModel().setValue(content);
}
dispose() {
this.disposable.dispose();
this.events.clear();
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.new.content.${this.file.key}`, this.updateNewContent);
}
}
......@@ -174,10 +174,7 @@ export const stageChange = ({ commit, state }, path) => {
commit(types.STAGE_CHANGE, path);
if (stagedFile) {
eventHub.$emit(`editor.update.model.content.staged-${stagedFile.key}`, {
content: stagedFile.content,
changed: false,
});
eventHub.$emit(`editor.update.model.new.content.staged-${stagedFile.key}`, stagedFile.content);
}
};
......@@ -186,7 +183,7 @@ export const unstageChange = ({ commit }, path) => {
};
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;
}
......
......@@ -156,7 +156,7 @@ export default {
[types.ADD_PENDING_TAB](state, { file, keyPrefix = 'pending' }) {
const pendingTab = state.openFiles.find(f => f.path === file.path && f.pending);
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) {
......@@ -168,6 +168,7 @@ export default {
if (f.path === file.path) {
return acc.concat({
...f,
content: file.content,
active: true,
pending: true,
opened: true,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册