1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 15:09:14 +00:00

Column update (#3434)

This commit is contained in:
zxj96
2019-05-10 15:40:01 +08:00
committed by Daniel Pan
parent b6ea393bc3
commit 4d00ba9d58

View File

@@ -191,11 +191,24 @@ class LibContentView extends React.Component {
}
let repoID = this.props.repoID;
let { path, dirID } = this.state;
seafileAPI.dirMetaData(repoID, path).then((res) => {
if (res.data.id !== dirID) {
this.loadDirentList(this.state.path);
if (this.state.currentMode === 'column') {
if (this.state.isViewFile) {
this.updataColumnMarkdownData(path)
} else {
seafileAPI.dirMetaData(repoID, path).then((res) => {
if (res.data.id !== dirID) {
this.loadDirentList(path);
}
})
}
});
} else {
seafileAPI.dirMetaData(repoID, path).then((res) => {
if (res.data.id !== dirID) {
this.loadDirentList(path);
}
})
}
}
updateUsedRepoTags = () => {
@@ -223,6 +236,43 @@ class LibContentView extends React.Component {
});
}
updataColumnMarkdownData = (filePath) => {
let repoID = this.props.repoID;
// update state
this.setState({
path: filePath,
isViewFile: true
});
// update data
seafileAPI.getFileInfo(repoID, filePath).then((res) => {
let { mtime, permission, last_modifier_name, is_draft, has_draft, draft_id } = res.data;
seafileAPI.getFileDownloadLink(repoID, filePath).then((res) => {
seafileAPI.getFileContent(res.data).then((res) => {
if (this.state.content !== res.data) {
this.setState({isFileLoading: true})
}
this.setState({
content: res.data,
filePermission: permission,
latestContributor: last_modifier_name,
lastModified: moment.unix(mtime).fromNow(),
isFileLoading: false,
isFileLoadedErr: false,
isDraft: is_draft,
hasDraft: has_draft,
draftID: draft_id
});
});
});
}).catch(() => {
this.setState({
isFileLoading: false,
isFileLoadedErr: true,
});
});
}
// load data
loadDirData = (path) => {
let repoID = this.props.repoID;