correctly toggle between tabs

This commit is contained in:
Phil Hughes 2018-03-23 11:37:34 +00:00
parent c5c7baec60
commit bfdeee1de9
No known key found for this signature in database
GPG Key ID: 32245528C52E0F9F
4 changed files with 18 additions and 9 deletions

View File

@ -71,7 +71,7 @@ export default {
this.getRawFileData(this.file)
.then(() => {
const viewerPromise = this.delayViewerUpdated
? this.updateViewer('editor')
? this.updateViewer(this.file.pending ? 'diff' : 'editor')
: Promise.resolve();
return viewerPromise;

View File

@ -37,9 +37,15 @@ export default {
},
methods: {
...mapActions(['closeFile']),
...mapActions(['closeFile', 'updateDelayViewerUpdated', 'openPendingTab']),
clickFile(tab) {
this.$router.push(`/project${tab.url}`);
this.updateDelayViewerUpdated(true);
if (tab.pending) {
this.openPendingTab(tab);
} else {
this.$router.push(`/project${tab.url}`);
}
},
mouseOverTab() {
if (this.tab.changed) {

View File

@ -80,7 +80,7 @@ export default class Model {
eventHub.$off(`editor.update.model.dispose.${this.file.key}`, this.dispose);
eventHub.$off(
`editor.update.model.content.${this.file.key}`,
`editor.update.model.content.${this.file.path}`,
this.updateContent,
);
}

View File

@ -92,6 +92,14 @@ export default {
[types.ADD_PENDING_TAB](state, file) {
const pendingTab = state.pendingTabs.find(f => f.path === file.path);
Object.assign(state, {
openFiles: state.openFiles.map(f =>
Object.assign(f, {
active: false,
}),
),
});
if (pendingTab) {
Object.assign(state, {
pendingTabs: state.pendingTabs.map(tab => ({
@ -107,11 +115,6 @@ export default {
pending: true,
key: `pending-${file.key}`,
}),
openFiles: state.openFiles.map(f =>
Object.assign(f, {
active: false,
}),
),
});
}
},