Show spinners when forward/back paginating.
This commit is contained in:
parent
2bd6529ca0
commit
e634f98a13
2 changed files with 28 additions and 0 deletions
|
@ -27,6 +27,14 @@ module.exports = React.createClass({
|
||||||
// true to give the component a 'display: none' style.
|
// true to give the component a 'display: none' style.
|
||||||
hidden: React.PropTypes.bool,
|
hidden: React.PropTypes.bool,
|
||||||
|
|
||||||
|
// true to show a spinner at the top of the timeline to indicate
|
||||||
|
// back-pagination in progress
|
||||||
|
backPaginating: React.PropTypes.bool,
|
||||||
|
|
||||||
|
// true to show a spinner at the end of the timeline to indicate
|
||||||
|
// forward-pagination in progress
|
||||||
|
forwardPaginating: React.PropTypes.bool,
|
||||||
|
|
||||||
// the list of MatrixEvents to display
|
// the list of MatrixEvents to display
|
||||||
events: React.PropTypes.array.isRequired,
|
events: React.PropTypes.array.isRequired,
|
||||||
|
|
||||||
|
@ -328,13 +336,24 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var ScrollPanel = sdk.getComponent("structures.ScrollPanel");
|
var ScrollPanel = sdk.getComponent("structures.ScrollPanel");
|
||||||
|
var Spinner = sdk.getComponent("elements.Spinner");
|
||||||
|
var topSpinner, bottomSpinner;
|
||||||
|
if (this.props.backPaginating) {
|
||||||
|
topSpinner = <li key="_topSpinner"><Spinner /></li>;
|
||||||
|
}
|
||||||
|
if (this.props.forwardPaginating) {
|
||||||
|
bottomSpinner = <li key="_bottomSpinner"><Spinner /></li>;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollPanel ref="scrollPanel" className="mx_RoomView_messagePanel"
|
<ScrollPanel ref="scrollPanel" className="mx_RoomView_messagePanel"
|
||||||
onScroll={ this.props.onScroll }
|
onScroll={ this.props.onScroll }
|
||||||
onFillRequest={ this.props.onFillRequest }
|
onFillRequest={ this.props.onFillRequest }
|
||||||
style={ this.props.hidden ? { display: 'none' } : {} }
|
style={ this.props.hidden ? { display: 'none' } : {} }
|
||||||
stickyBottom={ this.props.stickyBottom }>
|
stickyBottom={ this.props.stickyBottom }>
|
||||||
|
{topSpinner}
|
||||||
{this._getEventTiles()}
|
{this._getEventTiles()}
|
||||||
|
{bottomSpinner}
|
||||||
</ScrollPanel>
|
</ScrollPanel>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -102,6 +102,9 @@ var TimelinePanel = React.createClass({
|
||||||
readMarkerVisible: true,
|
readMarkerVisible: true,
|
||||||
|
|
||||||
readMarkerEventId: initialReadMarker,
|
readMarkerEventId: initialReadMarker,
|
||||||
|
|
||||||
|
backPaginating: false,
|
||||||
|
forwardPaginating: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -154,8 +157,12 @@ var TimelinePanel = React.createClass({
|
||||||
return q(false);
|
return q(false);
|
||||||
}
|
}
|
||||||
debuglog("TimelinePanel: Initiating paginate; backwards:"+backwards);
|
debuglog("TimelinePanel: Initiating paginate; backwards:"+backwards);
|
||||||
|
var statekey = backwards ? 'backPaginating' : 'forwardPaginating';
|
||||||
|
this.setState({[statekey]: true});
|
||||||
|
|
||||||
return this._timelineWindow.paginate(dir, PAGINATE_SIZE).then((r) => {
|
return this._timelineWindow.paginate(dir, PAGINATE_SIZE).then((r) => {
|
||||||
debuglog("TimelinePanel: paginate complete backwards:"+backwards+"; success:"+r);
|
debuglog("TimelinePanel: paginate complete backwards:"+backwards+"; success:"+r);
|
||||||
|
this.setState({[statekey]: false});
|
||||||
this._onTimelineUpdated(r);
|
this._onTimelineUpdated(r);
|
||||||
return r;
|
return r;
|
||||||
});
|
});
|
||||||
|
@ -615,6 +622,8 @@ var TimelinePanel = React.createClass({
|
||||||
return (
|
return (
|
||||||
<MessagePanel ref="messagePanel"
|
<MessagePanel ref="messagePanel"
|
||||||
hidden={ this.props.hidden }
|
hidden={ this.props.hidden }
|
||||||
|
backPaginating={ this.state.backPaginating }
|
||||||
|
forwardPaginating={ this.state.forwardPaginating }
|
||||||
events={ this.state.events }
|
events={ this.state.events }
|
||||||
highlightedEventId={ this.props.highlightedEventId }
|
highlightedEventId={ this.props.highlightedEventId }
|
||||||
readMarkerEventId={ this.state.readMarkerEventId }
|
readMarkerEventId={ this.state.readMarkerEventId }
|
||||||
|
|
Loading…
Reference in a new issue