);
+ lastRoomId = roomId;
+ }
}
- var resultList = roomIdGroups[roomId].results.map(function(eventId) { return results[eventId]; });
- for (var i = resultList.length - 1; i >= 0; i--) {
- var ts1 = resultList[i].result.origin_server_ts;
- ret.push(
); // Rank: {resultList[i].rank}
- var mxEv = new Matrix.MatrixEvent(resultList[i].result);
- if (resultList[i].context.events_before[0]) {
- var mxEv2 = new Matrix.MatrixEvent(resultList[i].context.events_before[0]);
- if (EventTile.haveTileForEvent(mxEv2)) {
- ret.push(
);
- }
- if (resultList[i].context.events_after[0]) {
- var mxEv2 = new Matrix.MatrixEvent(resultList[i].context.events_after[0]);
- if (EventTile.haveTileForEvent(mxEv2)) {
- ret.push(
);
- }
+ var ts1 = result.result.origin_server_ts;
+ ret.push(
); // Rank: {resultList[i].rank}
+
+ if (result.context.events_before[0]) {
+ var mxEv2 = new Matrix.MatrixEvent(result.context.events_before[0]);
+ if (EventTile.haveTileForEvent(mxEv2)) {
+ ret.push(
);
}
}
- });
+
+ ret.push(
);
+
+ if (result.context.events_after[0]) {
+ var mxEv2 = new Matrix.MatrixEvent(result.context.events_after[0]);
+ if (EventTile.haveTileForEvent(mxEv2)) {
+ ret.push(
);
if (dateSeparator) {
ret.unshift(dateSeparator);
}
++count;
}
- this.lastEventTileCount = count;
return ret;
},
@@ -849,7 +906,7 @@ module.exports = React.createClass({
},
onCancelClick: function() {
- this.setState(this.getInitialState());
+ this.setState({editingRoomSettings: false});
},
onLeaveClick: function() {
@@ -857,7 +914,19 @@ module.exports = React.createClass({
action: 'leave_room',
room_id: this.props.roomId,
});
- this.props.onFinished();
+ },
+
+ onForgetClick: function() {
+ MatrixClientPeg.get().forget(this.props.roomId).done(function() {
+ dis.dispatch({ action: 'view_next_room' });
+ }, function(err) {
+ var errCode = err.errcode || "unknown error code";
+ var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
+ Modal.createDialog(ErrorDialog, {
+ title: "Error",
+ description: `Failed to forget room (${errCode})`
+ });
+ });
},
onRejectButtonClicked: function(ev) {
@@ -883,6 +952,13 @@ module.exports = React.createClass({
this.setState({ searching: true });
},
+ onCancelSearchClick: function () {
+ this.setState({
+ searching: false,
+ searchResults: null,
+ });
+ },
+
onConferenceNotificationClick: function() {
dis.dispatch({
action: 'place_call',
@@ -910,12 +986,6 @@ module.exports = React.createClass({
// pixel_offset gives the number of pixels between the bottom of the event
// and the bottom of the container.
scrollToEvent: function(eventId, pixelOffset) {
- var scrollNode = this._getScrollNode();
- if (!scrollNode) return;
-
- var messageWrapper = this.refs.messagePanel;
- if (messageWrapper === undefined) return;
-
var idx = this._indexForEventId(eventId);
if (idx === null) {
// we don't seem to have this event in our timeline. Presumably
@@ -925,7 +995,7 @@ module.exports = React.createClass({
//
// for now, just scroll to the top of the buffer.
console.log("Refusing to scroll to unknown event "+eventId);
- scrollNode.scrollTop = 0;
+ this._getScrollNode().scrollTop = 0;
return;
}
@@ -943,14 +1013,88 @@ module.exports = React.createClass({
this.setState({messageCap: minCap});
}
- var node = this.eventNodes[eventId];
- if (node === null) {
- // getEventTiles should have sorted this out when we set the
- // messageCap, so this is weird.
- console.error("No node for event, even after rolling back messageCap");
+ // the scrollTokens on our DOM nodes are the event IDs, so we can pass
+ // eventId directly into _scrollToToken.
+ this._scrollToToken(eventId, pixelOffset);
+ },
+
+ _restoreSavedScrollState: function() {
+ var scrollState = this.state.searchResults ? this.savedSearchScrollState : this.savedScrollState;
+ if (!scrollState || scrollState.atBottom) {
+ this.scrollToBottom();
+ } else if (scrollState.lastDisplayedScrollToken) {
+ this._scrollToToken(scrollState.lastDisplayedScrollToken,
+ scrollState.pixelOffset);
+ }
+ },
+
+ _calculateScrollState: function() {
+ // we don't save the absolute scroll offset, because that
+ // would be affected by window width, zoom level, amount of scrollback,
+ // etc.
+ //
+ // instead we save an identifier for the last fully-visible message,
+ // and the number of pixels the window was scrolled below it - which
+ // will hopefully be near enough.
+ //
+ // Our scroll implementation is agnostic of the precise contents of the
+ // message list (since it needs to work with both search results and
+ // timelines). 'refs.messageList' is expected to be a DOM node with a
+ // number of children, each of which may have a 'data-scroll-token'
+ // attribute. It is this token which is stored as the
+ // 'lastDisplayedScrollToken'.
+
+ var messageWrapperScroll = this._getScrollNode();
+ // + 1 here to avoid fractional pixel rounding errors
+ var atBottom = messageWrapperScroll.scrollHeight - messageWrapperScroll.scrollTop <= messageWrapperScroll.clientHeight + 1;
+
+ var messageWrapper = this.refs.messagePanel;
+ var wrapperRect = ReactDOM.findDOMNode(messageWrapper).getBoundingClientRect();
+ var messages = this.refs.messageList.children;
+
+ for (var i = messages.length-1; i >= 0; --i) {
+ var node = messages[i];
+ if (!node.dataset.scrollToken) continue;
+
+ var boundingRect = node.getBoundingClientRect();
+ if (boundingRect.bottom < wrapperRect.bottom) {
+ return {
+ atBottom: atBottom,
+ lastDisplayedScrollToken: node.dataset.scrollToken,
+ pixelOffset: wrapperRect.bottom - boundingRect.bottom,
+ }
+ }
+ }
+
+ // apparently the entire timeline is below the viewport. Give up.
+ return { atBottom: true };
+ },
+
+ // scroll the message list to the node with the given scrollToken. See
+ // notes in _calculateScrollState on how this works.
+ //
+ // pixel_offset gives the number of pixels between the bottom of the node
+ // and the bottom of the container.
+ _scrollToToken: function(scrollToken, pixelOffset) {
+ /* find the dom node with the right scrolltoken */
+ var node;
+ var messages = this.refs.messageList.children;
+ for (var i = messages.length-1; i >= 0; --i) {
+ var m = messages[i];
+ if (!m.dataset.scrollToken) continue;
+ if (m.dataset.scrollToken == scrollToken) {
+ node = m;
+ break;
+ }
+ }
+
+ if (!node) {
+ console.error("No node with scrollToken '"+scrollToken+"'");
return;
}
+ var scrollNode = this._getScrollNode();
+ var messageWrapper = this.refs.messagePanel;
var wrapperRect = ReactDOM.findDOMNode(messageWrapper).getBoundingClientRect();
var boundingRect = node.getBoundingClientRect();
var scrollDelta = boundingRect.bottom + pixelOffset - wrapperRect.bottom;
@@ -962,59 +1106,11 @@ module.exports = React.createClass({
}
if (DEBUG_SCROLL) {
- console.log("Scrolled to event", eventId, "+", pixelOffset+":", scrollNode.scrollTop, "(delta: "+scrollDelta+")");
+ console.log("Scrolled to token", node.dataset.scrollToken, "+", pixelOffset+":", scrollNode.scrollTop, "(delta: "+scrollDelta+")");
console.log("recentEventScroll now "+this.recentEventScroll);
}
},
- _restoreSavedScrollState: function() {
- var scrollState = this.savedScrollState;
- if (scrollState.atBottom) {
- this.scrollToBottom();
- } else if (scrollState.lastDisplayedEvent) {
- this.scrollToEvent(scrollState.lastDisplayedEvent,
- scrollState.pixelOffset);
- }
- },
-
- _calculateScrollState: function() {
- // we don't save the absolute scroll offset, because that
- // would be affected by window width, zoom level, amount of scrollback,
- // etc.
- //
- // instead we save the id of the last fully-visible event, and the
- // number of pixels the window was scrolled below it - which will
- // hopefully be near enough.
- //
- if (this.eventNodes === undefined) return null;
-
- var messageWrapper = this.refs.messagePanel;
- if (messageWrapper === undefined) return null;
- var wrapperRect = ReactDOM.findDOMNode(messageWrapper).getBoundingClientRect();
-
- var messageWrapperScroll = this._getScrollNode();
- // + 1 here to avoid fractional pixel rounding errors
- var atBottom = messageWrapperScroll.scrollHeight - messageWrapperScroll.scrollTop <= messageWrapperScroll.clientHeight + 1;
-
- for (var i = this.state.room.timeline.length-1; i >= 0; --i) {
- var ev = this.state.room.timeline[i];
- var node = this.eventNodes[ev.getId()];
- if (!node) continue;
-
- var boundingRect = node.getBoundingClientRect();
- if (boundingRect.bottom < wrapperRect.bottom) {
- return {
- atBottom: atBottom,
- lastDisplayedEvent: ev.getId(),
- pixelOffset: wrapperRect.bottom - boundingRect.bottom,
- }
- }
- }
-
- // apparently the entire timeline is below the viewport. Give up.
- return { atBottom: true };
- },
-
// get the current scroll position of the room, so that it can be
// restored when we switch back to it
getScrollState: function() {
@@ -1022,11 +1118,17 @@ module.exports = React.createClass({
},
restoreScrollState: function(scrollState) {
+ if (!this.refs.messagePanel) return;
+
if(scrollState.atBottom) {
// we were at the bottom before. Ideally we'd scroll to the
// 'read-up-to' mark here.
- } else if (scrollState.lastDisplayedEvent) {
- this.scrollToEvent(scrollState.lastDisplayedEvent,
+ } else if (scrollState.lastDisplayedScrollToken) {
+ // we might need to backfill, so we call scrollToEvent rather than
+ // _scrollToToken here. The scrollTokens on our DOM nodes are the
+ // event IDs, so lastDisplayedScrollToken will be the event ID we need,
+ // and we can pass it directly into scrollToEvent.
+ this.scrollToEvent(scrollState.lastDisplayedScrollToken,
scrollState.pixelOffset);
}
},
@@ -1222,7 +1324,7 @@ module.exports = React.createClass({
aux = ;
}
else if (this.state.searching) {
- aux = ;
+ aux = ;
}
var conferenceCallNotification = null;
@@ -1249,21 +1351,29 @@ module.exports = React.createClass({
}
var messageComposer, searchInfo;
- if (!this.state.searchResults) {
+ var canSpeak = (
+ // joined and not showing search results
+ myMember && (myMember.membership == 'join') && !this.state.searchResults
+ );
+ if (canSpeak) {
messageComposer =
}
- else {
+
+ // TODO: Why aren't we storing the term/scope/count in this format
+ // in this.state if this is what RoomHeader desires?
+ if (this.state.searchResults) {
searchInfo = {
searchTerm : this.state.searchTerm,
searchScope : this.state.searchScope,
searchCount : this.state.searchCount,
- }
+ };
}
var call = CallHandler.getCallForRoom(this.props.roomId);
+ //var call = CallHandler.getAnyActiveCall();
var inCall = false;
- if (call && this.state.callState != 'ended') {
+ if (call && (this.state.callState !== 'ended' && this.state.callState !== 'ringing')) {
inCall = true;
var zoomButton, voiceMuteButton, videoMuteButton;
@@ -1304,8 +1414,18 @@ module.exports = React.createClass({
return (
diff --git a/src/components/views/rooms/RoomHeader.js b/src/components/views/rooms/RoomHeader.js
index bc5c70ce08..13959a16b9 100644
--- a/src/components/views/rooms/RoomHeader.js
+++ b/src/components/views/rooms/RoomHeader.js
@@ -108,8 +108,10 @@ module.exports = React.createClass({
//
var searchStatus;
- if (this.props.searchInfo && this.props.searchInfo.searchTerm) {
- searchStatus =
({ this.props.searchInfo.searchCount } results)
;
+ // don't display the search count until the search completes and
+ // gives us a non-null searchCount.
+ if (this.props.searchInfo && this.props.searchInfo.searchCount !== null) {
+ searchStatus =
(~{ this.props.searchInfo.searchCount } results)
;
}
name =
@@ -134,7 +136,17 @@ module.exports = React.createClass({
if (this.props.onLeaveClick) {
leave_button =
-
+
+
;
+ }
+
+ var forget_button;
+ if (this.props.onForgetClick) {
+ forget_button =
+