From 1901fdf88941016e3d21de2b459735203392ef86 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 22 Sep 2015 22:57:27 +0200 Subject: [PATCH 1/3] oops, bogus commit --- skins/base/views/molecules/ContextualMenu.js | 35 -------------------- 1 file changed, 35 deletions(-) delete mode 100644 skins/base/views/molecules/ContextualMenu.js diff --git a/skins/base/views/molecules/ContextualMenu.js b/skins/base/views/molecules/ContextualMenu.js deleted file mode 100644 index 58c542ee6..000000000 --- a/skins/base/views/molecules/ContextualMenu.js +++ /dev/null @@ -1,35 +0,0 @@ -/* -Copyright 2015 OpenMarket Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -'use strict'; - -var React = require('react'); -var classNames = require('classnames'); - -var dis = require("../../../../src/dispatcher"); - -var MatrixClientPeg = require("../../../../src/MatrixClientPeg"); - -module.exports = React.createClass({ - displayName: 'ContextualMenu', - - render: function() { - return ( -
-
- ); - } -}); From a5a6a35122f38a1254e03cb1044245537cf0b60a Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 24 Sep 2015 00:19:40 +0200 Subject: [PATCH 2/3] don't blindly and inconsistently kill scrollbars --- skins/base/css/common.css | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/skins/base/css/common.css b/skins/base/css/common.css index d6c5e091e..8afba88ef 100644 --- a/skins/base/css/common.css +++ b/skins/base/css/common.css @@ -34,15 +34,6 @@ h2 { margin-bottom: 16px; } -/* FIXME: show them on hoverover, and fix for firefox */ -::-webkit-scrollbar { - display: none; -} - -html { - overflow: -moz-scrollbars-none; -} - .mx_ContextualMenu_background { position: fixed; top: 0; @@ -153,4 +144,4 @@ html { font-weight: bold; font-size: 20px; line-height: 1.4; -} \ No newline at end of file +} From 5fe41e28d7eea785562e850f4cd2c64a3626e51b Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 24 Sep 2015 01:58:21 +0200 Subject: [PATCH 3/3] make presence work better on the memberlist. kludges around lack of syjs-28. is about as good as angular was now. --- skins/base/views/molecules/MemberTile.js | 4 +-- skins/base/views/organisms/MemberList.js | 14 +--------- src/controllers/organisms/MemberList.js | 34 +++++++++++++++++++----- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/skins/base/views/molecules/MemberTile.js b/skins/base/views/molecules/MemberTile.js index 1414b562d..d65cd0ed2 100644 --- a/skins/base/views/molecules/MemberTile.js +++ b/skins/base/views/molecules/MemberTile.js @@ -131,9 +131,9 @@ module.exports = React.createClass({ if (this.state.hover || this.state.menu) { var presence; // FIXME: make presence data update whenever User.presence changes... - var active = this.props.member.user ? (this.props.member.user.lastActiveAgo || -1) : -1; + var active = this.props.member.user ? ((Date.now() - (this.props.member.user.lastPresenceTs - this.props.member.user.lastActiveAgo)) || -1) : -1; if (active >= 0) { - presence =
{ this.getPrettyPresence(this.props.member.user) } for { this.getDuration(active) }
; + presence =
{ this.getPrettyPresence(this.props.member.user) } { this.getDuration(active) } ago
; } else { presence =
{ this.getPrettyPresence(this.props.member.user) }
; diff --git a/skins/base/views/organisms/MemberList.js b/skins/base/views/organisms/MemberList.js index a9a3c782a..1786db48b 100644 --- a/skins/base/views/organisms/MemberList.js +++ b/skins/base/views/organisms/MemberList.js @@ -35,18 +35,6 @@ module.exports = React.createClass({ return { editing: false }; }, - // FIXME: combine this more nicely with the MemberInfo positioning stuff... - onMemberListScroll: function(ev) { - if (this.refs.memberListScroll) { - var memberListScroll = this.refs.memberListScroll.getDOMNode(); - // offset the current MemberInfo bubble - var memberInfo = document.getElementsByClassName("mx_MemberInfo")[0]; - if (memberInfo) { - memberInfo.style.top = (memberInfo.parentElement.offsetTop - memberListScroll.scrollTop) + "px"; - } - } - }, - makeMemberTiles: function() { var self = this; return Object.keys(self.state.memberDict).map(function(userId) { @@ -97,7 +85,7 @@ module.exports = React.createClass({
-
+

Members

{this.makeMemberTiles()} diff --git a/src/controllers/organisms/MemberList.js b/src/controllers/organisms/MemberList.js index 3eef007ed..e6ff65b85 100644 --- a/src/controllers/organisms/MemberList.js +++ b/src/controllers/organisms/MemberList.js @@ -48,6 +48,8 @@ module.exports = { componentDidMount: function() { var self = this; + + // Lazy-load in more than the first N members setTimeout(function() { if (!self.isMounted()) return; self.setState({ @@ -59,13 +61,23 @@ module.exports = { // member tile and re-render it. This is more efficient than every tile // evar attaching their own listener. function updateUserState(event, user) { + // evil hack to track the age of this presence info. + // this should be removed once syjs-28 is resolved in the JS SDK itself. + user.lastPresenceTs = Date.now(); + var tile = self.refs[user.userId]; + + console.log("presence event " + JSON.stringify(event) + " user = " + user + " tile = " + tile); + if (tile) { - // update the whole list to get the order right, not just this cell... - self.forceUpdate(); - // tile.forceUpdate(); + self._updateList(); // reorder the membership list + self.forceUpdate(); // FIXME: is the a more efficient way of reordering with react? + // XXX: do we even need to do this, or is it done by the main list? + tile.forceUpdate(); } } + // FIXME: we should probably also reset 'lastActiveAgo' to zero whenever + // we see a typing notif from a user, as we don't get presence updates for those. MatrixClientPeg.get().on("User.presence", updateUserState); this.userPresenceFn = updateUserState; }, @@ -136,17 +148,23 @@ module.exports = { var all_members = room.currentState.members; var all_user_ids = Object.keys(all_members); + // XXX: dirty hack until SYJS-28 is fixed + all_user_ids.map(function(userId) { + if (all_members[userId].user && !all_members[userId].user.lastPresenceTs) { + all_members[userId].user.lastPresenceTs = Date.now(); + } + }); + all_user_ids.sort(function(userIdA, userIdB) { var userA = all_members[userIdA].user; var userB = all_members[userIdB].user; - var latA = userA ? userA.lastActiveAgo || Number.MAX_VALUE : Number.MAX_VALUE; - var latB = userB ? userB.lastActiveAgo || Number.MAX_VALUE : Number.MAX_VALUE; + var latA = userA ? (userA.lastPresenceTs - (userA.lastActiveAgo || userA.lastPresenceTs)) : 0; + var latB = userB ? (userB.lastPresenceTs - (userB.lastActiveAgo || userB.lastPresenceTs)) : 0; - return latA - latB; + return latB - latA; }); - var to_display = {}; var count = 0; for (var i = 0; i < all_user_ids.length && (limit === undefined || count < limit); ++i) { @@ -154,6 +172,8 @@ module.exports = { var m = all_members[user_id]; if (m.membership == 'join' || m.membership == 'invite') { + // XXX: this is evil, and relies on the fact that Object.keys() iterates + // over the keys of a dict in insertion order (if those keys are strings) to_display[user_id] = m; ++count; }