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

Merge pull request #3349 from haiwen/list-optimization

List optimization
This commit is contained in:
Daniel Pan
2019-04-24 15:27:04 +08:00
committed by GitHub
5 changed files with 35 additions and 4 deletions

View File

@@ -248,12 +248,16 @@ class DirColumnNav extends React.Component {
})); }));
} }
stopTreeScrollPropagation = (e) => {
e.stopPropagation();
}
render() { render() {
let flex = this.props.navRate ? '0 0 ' + this.props.navRate * 100 + '%' : '0 0 25%'; let flex = this.props.navRate ? '0 0 ' + this.props.navRate * 100 + '%' : '0 0 25%';
const select = this.props.inResizing ? 'none' : ''; const select = this.props.inResizing ? 'none' : '';
return ( return (
<Fragment> <Fragment>
<div className="dir-content-nav" role="navigation" style={{flex: (flex), userSelect: select}}> <div className="dir-content-nav" role="navigation" style={{flex: (flex), userSelect: select}} onScroll={this.stopTreeScrollPropagation}>
{this.props.isTreeDataLoading ? {this.props.isTreeDataLoading ?
(<Loading/>) : (<Loading/>) :
(<TreeView (<TreeView

View File

@@ -29,6 +29,7 @@ const propTypes = {
showShareBtn: PropTypes.bool.isRequired, showShareBtn: PropTypes.bool.isRequired,
showDirentDetail: PropTypes.func.isRequired, showDirentDetail: PropTypes.func.isRequired,
onAddFolder: PropTypes.func.isRequired, onAddFolder: PropTypes.func.isRequired,
onFileTagChanged: PropTypes.func,
}; };
class DirGridView extends React.Component { class DirGridView extends React.Component {
@@ -53,6 +54,7 @@ class DirGridView extends React.Component {
draftCounts={this.props.draftCounts} draftCounts={this.props.draftCounts}
usedRepoTags={this.props.usedRepoTags} usedRepoTags={this.props.usedRepoTags}
updateUsedRepoTags={this.props.updateUsedRepoTags} updateUsedRepoTags={this.props.updateUsedRepoTags}
onFileTagChanged={this.props.onFileTagChanged}
/> />
)} )}
<DirentGridView <DirentGridView

View File

@@ -85,6 +85,7 @@ const propTypes = {
showDirentDetail: PropTypes.func.isRequired, showDirentDetail: PropTypes.func.isRequired,
onDeleteRepoTag: PropTypes.func.isRequired, onDeleteRepoTag: PropTypes.func.isRequired,
updateDetail: PropTypes.bool.isRequired, updateDetail: PropTypes.bool.isRequired,
onListContainerScroll: PropTypes.func.isRequired,
}; };
class LibContentContainer extends React.Component { class LibContentContainer extends React.Component {
@@ -138,6 +139,13 @@ class LibContentContainer extends React.Component {
this.props.onItemDelete(dirent); this.props.onItemDelete(dirent);
} }
onItemsScroll = (e) => {
let target = e.target;
if (target.scrollTop + document.documentElement.clientHeight - target.offsetTop >= target.scrollHeight) {
this.props.onListContainerScroll();
}
}
render() { render() {
let { path, repoID, usedRepoTags, readmeMarkdown, draftCounts } = this.props; let { path, repoID, usedRepoTags, readmeMarkdown, draftCounts } = this.props;
let isRepoInfoBarShow = false; let isRepoInfoBarShow = false;
@@ -165,7 +173,7 @@ class LibContentContainer extends React.Component {
onDeleteRepoTag={this.props.onDeleteRepoTag} onDeleteRepoTag={this.props.onDeleteRepoTag}
/> />
</div> </div>
<div className={`cur-view-content lib-content-container ${this.props.currentMode === 'column' ? 'view-mode-container' : ''}`}> <div className={`cur-view-content lib-content-container ${this.props.currentMode === 'column' ? 'view-mode-container' : ''}`} onScroll={this.onItemsScroll}>
{!this.props.pathExist && this.errMessage} {!this.props.pathExist && this.errMessage}
{this.props.pathExist && ( {this.props.pathExist && (
<Fragment> <Fragment>
@@ -234,6 +242,7 @@ class LibContentContainer extends React.Component {
onGridItemClick={this.onGridItemClick} onGridItemClick={this.onGridItemClick}
isDirentDetailShow={this.props.isDirentDetailShow} isDirentDetailShow={this.props.isDirentDetailShow}
onItemRename={this.props.onItemRename} onItemRename={this.props.onItemRename}
onFileTagChanged={this.props.onFileTagChanged}
/> />
)} )}
{this.props.currentMode === 'column' && ( {this.props.currentMode === 'column' && (

View File

@@ -71,6 +71,7 @@ class LibContentView extends React.Component {
errorMsg: '', errorMsg: '',
isDirentDetailShow: false, isDirentDetailShow: false,
updateDetail: false, updateDetail: false,
itemsShowLength: 100,
}; };
this.oldonpopstate = window.onpopstate; this.oldonpopstate = window.onpopstate;
@@ -404,6 +405,7 @@ class LibContentView extends React.Component {
if (!this.state.repoEncrypted && direntList.length) { if (!this.state.repoEncrypted && direntList.length) {
this.getThumbnails(repoID, path, this.state.direntList); this.getThumbnails(repoID, path, this.state.direntList);
} }
this.resetShowLength();
}).catch(() => { }).catch(() => {
this.setState({ this.setState({
isDirentListLoading: false, isDirentListLoading: false,
@@ -412,6 +414,15 @@ class LibContentView extends React.Component {
}); });
} }
onListContainerScroll = () => {
let itemsShowLength = this.state.itemsShowLength + 100;
this.setState({itemsShowLength: itemsShowLength});
}
resetShowLength = () => {
this.setState({itemsShowLength: 100});
}
getThumbnails = (repoID, path, direntList) => { getThumbnails = (repoID, path, direntList) => {
let items = direntList.filter((item) => { let items = direntList.filter((item) => {
return Utils.imageCheck(item.name) && !item.encoded_thumbnail_src; return Utils.imageCheck(item.name) && !item.encoded_thumbnail_src;
@@ -1336,6 +1347,10 @@ class LibContentView extends React.Component {
} }
let direntItemsList = this.state.direntList.filter((item, index) => {
return index < this.state.itemsShowLength;
})
return ( return (
<div className="main-panel o-hidden"> <div className="main-panel o-hidden">
<div className="main-panel-north border-left-show"> <div className="main-panel-north border-left-show">
@@ -1423,7 +1438,7 @@ class LibContentView extends React.Component {
readmeMarkdown={this.state.readmeMarkdown} readmeMarkdown={this.state.readmeMarkdown}
updateUsedRepoTags={this.updateUsedRepoTags} updateUsedRepoTags={this.updateUsedRepoTags}
isDirentListLoading={this.state.isDirentListLoading} isDirentListLoading={this.state.isDirentListLoading}
direntList={this.state.direntList} direntList={direntItemsList}
showShareBtn={showShareBtn} showShareBtn={showShareBtn}
sortBy={this.state.sortBy} sortBy={this.state.sortBy}
sortOrder={this.state.sortOrder} sortOrder={this.state.sortOrder}
@@ -1453,6 +1468,7 @@ class LibContentView extends React.Component {
onDeleteRepoTag={this.onDeleteRepoTag} onDeleteRepoTag={this.onDeleteRepoTag}
onToolbarFileTagChanged={this.onToolbarFileTagChanged} onToolbarFileTagChanged={this.onToolbarFileTagChanged}
updateDetail={this.state.updateDetail} updateDetail={this.state.updateDetail}
onListContainerScroll={this.onListContainerScroll}
/> />
{this.state.pathExist && !this.state.isViewFile && ( {this.state.pathExist && !this.state.isViewFile && (
<FileUploader <FileUploader