Add plain property to active file if not set already

上级 00e7f328
......@@ -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,
......
......@@ -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.');
},
......
/* 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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册