mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-17 05:55:00 +08:00
Tweaks to the semantics for sending RRs and handling room switches
* Only send read receipts when we are at the bottom of a room; this is a simple and effective way of stopping the green bar of doom from jumping down the room slightly behind the scroll. * Jump to read-up-to mark when switching back to a room if we were following the live timeline before.
This commit is contained in:
parent
d1467d2319
commit
d14c1a82b2
@ -252,6 +252,8 @@ module.exports = React.createClass({
|
|||||||
} else {
|
} else {
|
||||||
this.refs.messagePanel.scrollToBottom();
|
this.refs.messagePanel.scrollToBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.sendReadReceipt();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -631,9 +633,6 @@ module.exports = React.createClass({
|
|||||||
_initialiseMessagePanel: function() {
|
_initialiseMessagePanel: function() {
|
||||||
var messagePanel = ReactDOM.findDOMNode(this.refs.messagePanel);
|
var messagePanel = ReactDOM.findDOMNode(this.refs.messagePanel);
|
||||||
this.refs.messagePanel.initialised = true;
|
this.refs.messagePanel.initialised = true;
|
||||||
|
|
||||||
this.sendReadReceipt();
|
|
||||||
|
|
||||||
this.updateTint();
|
this.updateTint();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1323,6 +1322,13 @@ module.exports = React.createClass({
|
|||||||
if (!this.state.room) return;
|
if (!this.state.room) return;
|
||||||
if (!this.refs.messagePanel) return;
|
if (!this.refs.messagePanel) return;
|
||||||
|
|
||||||
|
// we don't want to see our RR marker dropping down as we scroll
|
||||||
|
// through old history. For now, do this just by leaving the RR where
|
||||||
|
// it is until we hit the bottom of the room, though ultimately we
|
||||||
|
// probably want to keep sending RR, but hide the RR until we reach
|
||||||
|
// the bottom of the room again, or something.
|
||||||
|
if (!this.state.atEndOfLiveTimeline) return;
|
||||||
|
|
||||||
var currentReadUpToEventId = this.state.room.getEventReadUpTo(MatrixClientPeg.get().credentials.userId);
|
var currentReadUpToEventId = this.state.room.getEventReadUpTo(MatrixClientPeg.get().credentials.userId);
|
||||||
var currentReadUpToEventIndex = this._indexForEventId(currentReadUpToEventId);
|
var currentReadUpToEventIndex = this._indexForEventId(currentReadUpToEventId);
|
||||||
|
|
||||||
@ -1510,7 +1516,9 @@ module.exports = React.createClass({
|
|||||||
// get the current scroll position of the room, so that it can be
|
// get the current scroll position of the room, so that it can be
|
||||||
// restored when we switch back to it.
|
// restored when we switch back to it.
|
||||||
//
|
//
|
||||||
// This returns an object with the following properties:
|
// If there is no special scroll state (ie, we are following the live
|
||||||
|
// timeline), returns null. Otherwise, returns an object with the following
|
||||||
|
// properties:
|
||||||
//
|
//
|
||||||
// focussedEvent: the ID of the 'focussed' event. Typically this is the
|
// focussedEvent: the ID of the 'focussed' event. Typically this is the
|
||||||
// last event fully visible in the viewport, though if we have done
|
// last event fully visible in the viewport, though if we have done
|
||||||
@ -1519,12 +1527,23 @@ module.exports = React.createClass({
|
|||||||
// pixelOffset: the number of pixels the window is scrolled down from
|
// pixelOffset: the number of pixels the window is scrolled down from
|
||||||
// the focussedEvent.
|
// the focussedEvent.
|
||||||
//
|
//
|
||||||
// If there are no visible events, returns null.
|
|
||||||
//
|
//
|
||||||
getScrollState: function() {
|
getScrollState: function() {
|
||||||
var messagePanel = this.refs.messagePanel;
|
var messagePanel = this.refs.messagePanel;
|
||||||
if (!messagePanel) return null;
|
if (!messagePanel) return null;
|
||||||
|
|
||||||
|
// if we're following the live timeline, we want to return null; that
|
||||||
|
// means that, if we switch back, we will jump to the read-up-to mark.
|
||||||
|
//
|
||||||
|
// That should be more intuitive than slavishly preserving the current
|
||||||
|
// scroll state, in the case where the room advances in the meantime
|
||||||
|
// (particularly in the case that the user reads some stuff on another
|
||||||
|
// device).
|
||||||
|
//
|
||||||
|
if (this.state.atEndOfLiveTimeline) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var scrollState = messagePanel.getScrollState();
|
var scrollState = messagePanel.getScrollState();
|
||||||
|
|
||||||
if (scrollState.stuckAtBottom) {
|
if (scrollState.stuckAtBottom) {
|
||||||
|
Loading…
Reference in New Issue
Block a user