[ci skip] WIP start to fix file raw state
This commit is contained in:
parent
e361ed1e31
commit
2fce0c86e5
2 changed files with 19 additions and 11 deletions
|
@ -166,22 +166,17 @@ const RepoHelper = {
|
|||
const rawUrl = RepoHelper.getRawURLFromBlobURL(file.url || Service.url);
|
||||
RepoHelper.setBinaryDataAsBase64(rawUrl, data);
|
||||
Store.setViewToPreview();
|
||||
} else {
|
||||
if (!Store.isPreviewView()) {
|
||||
} else if (!Store.isPreviewView()) {
|
||||
Service.getRaw(data.raw_path)
|
||||
.then((rawResponse) => {
|
||||
Store.blobRaw = rawResponse.data;
|
||||
data.plain = rawResponse.data;
|
||||
|
||||
RepoHelper.setFile(data, file);
|
||||
}).catch(RepoHelper.loadingError);
|
||||
}
|
||||
}
|
||||
|
||||
if (!file.url) file.url = location.pathname;
|
||||
|
||||
data.url = file.url;
|
||||
data.newContent = '';
|
||||
|
||||
Store.addToOpenedFiles(data);
|
||||
Store.setActiveFiles(data);
|
||||
if (Store.isPreviewView()) RepoHelper.setFile(data, file);
|
||||
|
||||
// if the file tree is empty
|
||||
if (Store.files.length === 0) {
|
||||
|
@ -200,6 +195,17 @@ const RepoHelper = {
|
|||
}).catch(RepoHelper.loadingError);
|
||||
},
|
||||
|
||||
setFile(data, file) {
|
||||
const newFile = data;
|
||||
|
||||
newFile.url = file.url || location.pathname;
|
||||
newFile.url = file.url;
|
||||
newFile.newContent = '';
|
||||
|
||||
Store.addToOpenedFiles(newFile);
|
||||
Store.setActiveFiles(newFile);
|
||||
},
|
||||
|
||||
toFA(icon) {
|
||||
return `fa-${icon}`;
|
||||
},
|
||||
|
|
|
@ -95,6 +95,8 @@ const RepoStore = {
|
|||
if (file.binary) {
|
||||
RepoStore.blobRaw = file.base64;
|
||||
RepoStore.binaryMimeType = file.mime_type;
|
||||
} else {
|
||||
RepoStore.blobRaw = file.newContent || file.plain;
|
||||
}
|
||||
|
||||
if (!file.loading) RepoHelper.toURL(file.url, file.name);
|
||||
|
|
Loading…
Reference in a new issue