Add plain property to active file if not set already

This commit is contained in:
Luke "Jared" Bennett 2017-08-03 19:52:18 +01:00
parent 00e7f3284c
commit 1530b1e6b9
No known key found for this signature in database
GPG key ID: 402ED51FB5D306C2
3 changed files with 13 additions and 2 deletions

View file

@ -11,7 +11,7 @@ const RepoEditor = {
Service.getRaw(this.activeFile.raw_path)
.then((rawResponse) => {
Store.blobRaw = rawResponse.data;
this.openedFiles[0].plain = rawResponse.data;
Helper.findOpenedFileFromActive().plain = rawResponse.data;
const monacoInstance = this.monaco.editor.create(this.$el, {
model: null,

View file

@ -289,6 +289,10 @@ const RepoHelper = {
}
},
findOpenedFileFromActive() {
return Store.openedFiles.find(openedFile => Store.activeFile.url === openedFile.url);
},
loadingError() {
Flash('Unable to load the file at this time.');
},

View file

@ -1,5 +1,6 @@
/* global Flash */
import RepoHelper from '../helpers/repo_helper';
import RepoService from '../services/repo_service';
const RepoStore = {
ideEl: {},
@ -95,8 +96,14 @@ const RepoStore = {
if (file.binary) {
RepoStore.blobRaw = file.base64;
RepoStore.binaryMimeType = file.mime_type;
} else {
} else if (file.newContent || file.plain) {
RepoStore.blobRaw = file.newContent || file.plain;
} else {
RepoService.getRaw(file.raw_path)
.then((rawResponse) => {
RepoStore.blobRaw = rawResponse.data;
RepoHelper.findOpenedFileFromActive().plain = rawResponse.data;
}).catch(RepoHelper.loadingError);
}
if (!file.loading) RepoHelper.toURL(file.url, file.name);