mirror of https://github.com/vector-im/riot-web
Merge pull request #109 from matrix-org/kegan/room-swap-perf
Improve room swap performancepull/21833/head
commit
4775f39e1d
|
@ -67,14 +67,24 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
getOneToOneAvatar: function(props) {
|
getOneToOneAvatar: function(props) {
|
||||||
var userIds = Object.keys(props.room.currentState.members);
|
var mlist = props.room.currentState.members;
|
||||||
|
var userIds = [];
|
||||||
|
// for .. in optimisation to return early if there are >2 keys
|
||||||
|
for (var uid in mlist) {
|
||||||
|
if (mlist.hasOwnProperty(uid)) {
|
||||||
|
userIds.push(uid);
|
||||||
|
}
|
||||||
|
if (userIds.length > 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (userIds.length == 2) {
|
if (userIds.length == 2) {
|
||||||
var theOtherGuy = null;
|
var theOtherGuy = null;
|
||||||
if (props.room.currentState.members[userIds[0]].userId == MatrixClientPeg.get().credentials.userId) {
|
if (mlist[userIds[0]].userId == MatrixClientPeg.get().credentials.userId) {
|
||||||
theOtherGuy = props.room.currentState.members[userIds[1]];
|
theOtherGuy = mlist[userIds[1]];
|
||||||
} else {
|
} else {
|
||||||
theOtherGuy = props.room.currentState.members[userIds[0]];
|
theOtherGuy = mlist[userIds[0]];
|
||||||
}
|
}
|
||||||
return theOtherGuy.getAvatarUrl(
|
return theOtherGuy.getAvatarUrl(
|
||||||
MatrixClientPeg.get().getHomeserverUrl(),
|
MatrixClientPeg.get().getHomeserverUrl(),
|
||||||
|
@ -82,7 +92,7 @@ module.exports = React.createClass({
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
} else if (userIds.length == 1) {
|
} else if (userIds.length == 1) {
|
||||||
return props.room.currentState.members[userIds[0]].getAvatarUrl(
|
return mlist[userIds[0]].getAvatarUrl(
|
||||||
MatrixClientPeg.get().getHomeserverUrl(),
|
MatrixClientPeg.get().getHomeserverUrl(),
|
||||||
props.width, props.height, props.resizeMethod,
|
props.width, props.height, props.resizeMethod,
|
||||||
false
|
false
|
||||||
|
|
|
@ -20,6 +20,7 @@ var React = require('react');
|
||||||
var sdk = require('../../../index');
|
var sdk = require('../../../index');
|
||||||
var dis = require("../../../dispatcher");
|
var dis = require("../../../dispatcher");
|
||||||
var MatrixClientPeg = require('../../../MatrixClientPeg');
|
var MatrixClientPeg = require('../../../MatrixClientPeg');
|
||||||
|
var Modal = require("../../../Modal");
|
||||||
|
|
||||||
var linkify = require('linkifyjs');
|
var linkify = require('linkifyjs');
|
||||||
var linkifyElement = require('linkifyjs/element');
|
var linkifyElement = require('linkifyjs/element');
|
||||||
|
@ -103,17 +104,14 @@ module.exports = React.createClass({
|
||||||
console.error("No ChangeAvatar found to upload image to!");
|
console.error("No ChangeAvatar found to upload image to!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
changeAvatar.onFileSelected(ev).done(function() {
|
changeAvatar.onFileSelected(ev).catch(function(err) {
|
||||||
// dunno if the avatar changed, re-check it.
|
|
||||||
self._refreshFromServer();
|
|
||||||
}, function(err) {
|
|
||||||
var errMsg = (typeof err === "string") ? err : (err.error || "");
|
var errMsg = (typeof err === "string") ? err : (err.error || "");
|
||||||
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
Modal.createDialog(ErrorDialog, {
|
Modal.createDialog(ErrorDialog, {
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: "Failed to set avatar. " + errMsg
|
description: "Failed to set avatar. " + errMsg
|
||||||
});
|
});
|
||||||
});
|
}).done();
|
||||||
},
|
},
|
||||||
|
|
||||||
getRoomName: function() {
|
getRoomName: function() {
|
||||||
|
|
Loading…
Reference in New Issue