|
|
@ -67,7 +67,8 @@ let chat = create({
|
|
|
|
|
|
|
|
|
|
|
|
getInitialState: function() {
|
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
ref: null
|
|
|
|
ref: null,
|
|
|
|
|
|
|
|
loading: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
@ -98,6 +99,14 @@ let chat = create({
|
|
|
|
this.setState({replyEvent: e})
|
|
|
|
this.setState({replyEvent: e})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
paginateBackwards: function() {
|
|
|
|
|
|
|
|
let client = this.props.client
|
|
|
|
|
|
|
|
client.paginateEventTimeline(client.getRoom(this.props.roomId).getLiveTimeline(), {backwards: true}).then(() => {
|
|
|
|
|
|
|
|
this.setState({loading: false})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
this.setState({loading: true})
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
render: function() {
|
|
|
|
let client = this.props.client
|
|
|
|
let client = this.props.client
|
|
|
|
let empty = (
|
|
|
|
let empty = (
|
|
|
@ -124,9 +133,14 @@ let chat = create({
|
|
|
|
// if the sender is the same, add it to the 'current' messageGroup, if not,
|
|
|
|
// if the sender is the same, add it to the 'current' messageGroup, if not,
|
|
|
|
// push the old one to 'groups' and start with a new array.
|
|
|
|
// push the old one to 'groups' and start with a new array.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let liveTimeline = room.getLiveTimeline()
|
|
|
|
|
|
|
|
let liveTimelineEvents = liveTimeline.getEvents()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// fetch more backlog if we don't have enough events
|
|
|
|
|
|
|
|
|
|
|
|
let events = []
|
|
|
|
let events = []
|
|
|
|
if (room.timeline.length > 0) {
|
|
|
|
if (liveTimelineEvents.length > 0) {
|
|
|
|
room.getLiveTimeline().getEvents().forEach((MatrixEvent) => {
|
|
|
|
liveTimelineEvents.forEach((MatrixEvent) => {
|
|
|
|
let event = MatrixEvent.event;
|
|
|
|
let event = MatrixEvent.event;
|
|
|
|
event = Object.assign(event, eventFunctions)
|
|
|
|
event = Object.assign(event, eventFunctions)
|
|
|
|
if (event.sender == null) { // localecho messages
|
|
|
|
if (event.sender == null) { // localecho messages
|
|
|
@ -155,10 +169,12 @@ let chat = create({
|
|
|
|
<Info room={room} />
|
|
|
|
<Info room={room} />
|
|
|
|
<div className="chat" ref={this.setRef}>
|
|
|
|
<div className="chat" ref={this.setRef}>
|
|
|
|
<div className="events">
|
|
|
|
<div className="events">
|
|
|
|
<button onClick={() => {
|
|
|
|
<button onClick={this.paginateBackwards}>
|
|
|
|
this.props.client.paginateEventTimeline(room.getLiveTimeline(), {backwards: true})
|
|
|
|
|
|
|
|
}}>
|
|
|
|
|
|
|
|
load older messages</button>
|
|
|
|
load older messages</button>
|
|
|
|
|
|
|
|
{this.state.loading &&
|
|
|
|
|
|
|
|
<div className="loading">
|
|
|
|
|
|
|
|
LOADING
|
|
|
|
|
|
|
|
</div>}
|
|
|
|
{events}
|
|
|
|
{events}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|