mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-10 19:29:56 +00:00
New file history (#2359)
This commit is contained in:
committed by
Daniel Pan
parent
5924c65d08
commit
ca0110e996
@@ -0,0 +1,54 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import HisotyListItem from './history-list-item';
|
||||
import Loading from '../loading';
|
||||
|
||||
const propTypes = {
|
||||
hasMore: PropTypes.bool.isRequired,
|
||||
isReloadingData: PropTypes.bool.isRequired,
|
||||
isItemFrezeed: PropTypes.bool.isRequired,
|
||||
historyList: PropTypes.array.isRequired,
|
||||
currentItem: PropTypes.object,
|
||||
reloadMore: PropTypes.func.isRequired,
|
||||
onMenuControlClick: PropTypes.func.isRequired,
|
||||
onHistoryItemClick: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
class HistoryListView extends React.Component {
|
||||
|
||||
onScrollHandler = (event) => {
|
||||
const clientHeight = event.target.clientHeight;
|
||||
const scrollHeight = event.target.scrollHeight;
|
||||
const scrollTop = event.target.scrollTop;
|
||||
const isBottom = (clientHeight + scrollTop + 1 >= scrollHeight);
|
||||
let hasMore = this.props.hasMore;
|
||||
if (isBottom && hasMore) {
|
||||
this.props.reloadMore();
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<ul className="history-list-container" onScroll={this.onScrollHandler}>
|
||||
{this.props.historyList.map((item, index) => {
|
||||
return (
|
||||
<HisotyListItem
|
||||
key={index}
|
||||
item={item}
|
||||
isFirstItem={index === 0}
|
||||
currentItem={this.props.currentItem}
|
||||
isItemFrezeed={this.props.isItemFrezeed}
|
||||
onMenuControlClick={this.props.onMenuControlClick}
|
||||
onHistoryItemClick={this.props.onHistoryItemClick}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{this.props.isReloadingData && <li><Loading /></li>}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
HistoryListView.propTypes = propTypes;
|
||||
|
||||
export default HistoryListView;
|
Reference in New Issue
Block a user