Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Weblate 2018-10-10 14:59:06 +00:00
commit ff7365ddef
5 changed files with 42 additions and 26 deletions

View file

@ -68,7 +68,9 @@ module.exports = React.createClass({
if (oldNode && oldNode.style.visibility == 'hidden' && c.props.style.visibility == 'visible') { if (oldNode && oldNode.style.visibility == 'hidden' && c.props.style.visibility == 'visible') {
oldNode.style.visibility = c.props.style.visibility; oldNode.style.visibility = c.props.style.visibility;
} }
self.children[c.key] = old; // clone the old element with the props (and children) of the new element
// so prop updates are still received by the children.
self.children[c.key] = React.cloneElement(old, c.props, c.props.children);
} else { } else {
// new element. If we have a startStyle, use that as the style and go through // new element. If we have a startStyle, use that as the style and go through
// the enter animations // the enter animations

View file

@ -542,7 +542,7 @@ module.exports = React.createClass({
}, },
// get a list of read receipts that should be shown next to this event // get a list of read receipts that should be shown next to this event
// Receipts are objects which have a 'roomMember' and 'ts'. // Receipts are objects which have a 'userId', 'roomMember' and 'ts'.
_getReadReceiptsForEvent: function(event) { _getReadReceiptsForEvent: function(event) {
const myUserId = MatrixClientPeg.get().credentials.userId; const myUserId = MatrixClientPeg.get().credentials.userId;
@ -560,10 +560,8 @@ module.exports = React.createClass({
return; // ignore ignored users return; // ignore ignored users
} }
const member = room.getMember(r.userId); const member = room.getMember(r.userId);
if (!member) {
return; // ignore unknown user IDs
}
receipts.push({ receipts.push({
userId: r.userId,
roomMember: member, roomMember: member,
ts: r.data ? r.data.ts : 0, ts: r.data ? r.data.ts : 0,
}); });

View file

@ -26,7 +26,8 @@ module.exports = React.createClass({
displayName: 'MemberAvatar', displayName: 'MemberAvatar',
propTypes: { propTypes: {
member: PropTypes.object.isRequired, member: PropTypes.object,
fallbackUserId: PropTypes.string,
width: PropTypes.number, width: PropTypes.number,
height: PropTypes.number, height: PropTypes.number,
resizeMethod: PropTypes.string, resizeMethod: PropTypes.string,
@ -55,23 +56,30 @@ module.exports = React.createClass({
}, },
_getState: function(props) { _getState: function(props) {
if (!props.member) { if (props.member) {
console.error("MemberAvatar called somehow with null member"); return {
name: props.member.name,
title: props.title || props.member.userId,
imageUrl: Avatar.avatarUrlForMember(props.member,
props.width,
props.height,
props.resizeMethod),
};
} else if (props.fallbackUserId) {
return {
name: props.fallbackUserId,
title: props.fallbackUserId,
};
} else {
console.error("MemberAvatar called somehow with null member or fallbackUserId");
} }
return {
name: props.member.name,
title: props.title || props.member.userId,
imageUrl: Avatar.avatarUrlForMember(props.member,
props.width,
props.height,
props.resizeMethod),
};
}, },
render: function() { render: function() {
const BaseAvatar = sdk.getComponent("avatars.BaseAvatar"); const BaseAvatar = sdk.getComponent("avatars.BaseAvatar");
let {member, onClick, viewUserOnClick, ...otherProps} = this.props; let {member, fallbackUserId, onClick, viewUserOnClick, ...otherProps} = this.props;
let userId = member ? member.userId : fallbackUserId;
if (viewUserOnClick) { if (viewUserOnClick) {
onClick = () => { onClick = () => {
@ -84,7 +92,7 @@ module.exports = React.createClass({
return ( return (
<BaseAvatar {...otherProps} name={this.state.name} title={this.state.title} <BaseAvatar {...otherProps} name={this.state.name} title={this.state.title}
idName={member.userId} url={this.state.imageUrl} onClick={onClick} /> idName={userId} url={this.state.imageUrl} onClick={onClick} />
); );
}, },
}); });

View file

@ -277,7 +277,11 @@ module.exports = withMatrixClient(React.createClass({
return false; return false;
} }
for (let j = 0; j < rA.length; j++) { for (let j = 0; j < rA.length; j++) {
if (rA[j].roomMember.userId !== rB[j].roomMember.userId) { if (rA[j].userId !== rB[j].userId) {
return false;
}
// one has a member set and the other doesn't?
if (rA[j].roomMember !== rB[j].roomMember) {
return false; return false;
} }
} }
@ -359,7 +363,7 @@ module.exports = withMatrixClient(React.createClass({
// else set it proportional to index // else set it proportional to index
left = (hidden ? MAX_READ_AVATARS - 1 : i) * -receiptOffset; left = (hidden ? MAX_READ_AVATARS - 1 : i) * -receiptOffset;
const userId = receipt.roomMember.userId; const userId = receipt.userId;
let readReceiptInfo; let readReceiptInfo;
if (this.props.readReceiptMap) { if (this.props.readReceiptMap) {
@ -373,6 +377,7 @@ module.exports = withMatrixClient(React.createClass({
// add to the start so the most recent is on the end (ie. ends up rightmost) // add to the start so the most recent is on the end (ie. ends up rightmost)
avatars.unshift( avatars.unshift(
<ReadReceiptMarker key={userId} member={receipt.roomMember} <ReadReceiptMarker key={userId} member={receipt.roomMember}
fallbackUserId={userId}
leftOffset={left} hidden={hidden} leftOffset={left} hidden={hidden}
readReceiptInfo={readReceiptInfo} readReceiptInfo={readReceiptInfo}
checkUnmounting={this.props.checkUnmounting} checkUnmounting={this.props.checkUnmounting}

View file

@ -41,7 +41,10 @@ module.exports = React.createClass({
propTypes: { propTypes: {
// the RoomMember to show the RR for // the RoomMember to show the RR for
member: PropTypes.object.isRequired, member: PropTypes.object,
// userId to fallback the avatar to
// if the member hasn't been loaded yet
fallbackUserId: PropTypes.string.isRequired,
// number of pixels to offset the avatar from the right of its parent; // number of pixels to offset the avatar from the right of its parent;
// typically a negative value. // typically a negative value.
@ -130,8 +133,7 @@ module.exports = React.createClass({
// the docs for `offsetParent` say it may be null if `display` is // the docs for `offsetParent` say it may be null if `display` is
// `none`, but I can't see why that would happen. // `none`, but I can't see why that would happen.
console.warn( console.warn(
`ReadReceiptMarker for ${this.props.member.userId} in ` + `ReadReceiptMarker for ${this.props.fallbackUserId} in has no offsetParent`,
`${this.props.member.roomId} has no offsetParent`,
); );
startTopOffset = 0; startTopOffset = 0;
} else { } else {
@ -186,17 +188,17 @@ module.exports = React.createClass({
let title; let title;
if (this.props.timestamp) { if (this.props.timestamp) {
const dateString = formatDate(new Date(this.props.timestamp), this.props.showTwelveHour); const dateString = formatDate(new Date(this.props.timestamp), this.props.showTwelveHour);
if (this.props.member.userId === this.props.member.rawDisplayName) { if (!this.props.member || this.props.fallbackUserId === this.props.member.rawDisplayName) {
title = _t( title = _t(
"Seen by %(userName)s at %(dateTime)s", "Seen by %(userName)s at %(dateTime)s",
{userName: this.props.member.userId, {userName: this.props.fallbackUserId,
dateTime: dateString}, dateTime: dateString},
); );
} else { } else {
title = _t( title = _t(
"Seen by %(displayName)s (%(userName)s) at %(dateTime)s", "Seen by %(displayName)s (%(userName)s) at %(dateTime)s",
{displayName: this.props.member.rawDisplayName, {displayName: this.props.member.rawDisplayName,
userName: this.props.member.userId, userName: this.props.fallbackUserId,
dateTime: dateString}, dateTime: dateString},
); );
} }
@ -208,6 +210,7 @@ module.exports = React.createClass({
enterTransitionOpts={this.state.enterTransitionOpts} > enterTransitionOpts={this.state.enterTransitionOpts} >
<MemberAvatar <MemberAvatar
member={this.props.member} member={this.props.member}
fallbackUserId={this.props.fallbackUserId}
aria-hidden="true" aria-hidden="true"
width={14} height={14} resizeMethod="crop" width={14} height={14} resizeMethod="crop"
style={style} style={style}