From 28b42d512ad49359df2859e3cefa377fd42ec9ef Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Thu, 8 Aug 2019 20:07:38 +0100
Subject: [PATCH 1/4] Use the room name rather than sender name for fallback
room avatar event
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
.../views/messages/RoomAvatarEvent.js | 25 +++++++++++--------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/src/components/views/messages/RoomAvatarEvent.js b/src/components/views/messages/RoomAvatarEvent.js
index d035fc9237..72d0d1926a 100644
--- a/src/components/views/messages/RoomAvatarEvent.js
+++ b/src/components/views/messages/RoomAvatarEvent.js
@@ -31,12 +31,21 @@ module.exports = React.createClass({
mxEvent: PropTypes.object.isRequired,
},
- onAvatarClick: function(name) {
- const httpUrl = MatrixClientPeg.get().mxcUrlToHttp(this.props.mxEvent.getContent().url);
+ onAvatarClick: function() {
+ const cli = MatrixClientPeg.get();
+ const ev = this.props.mxEvent;
+ const httpUrl = cli.mxcUrlToHttp(ev.getContent().url);
+
+ const room = cli.getRoom(this.props.mxEvent.getRoomId());
+ const text = _t('%(senderDisplayName)s changed the avatar for %(roomName)s', {
+ senderDisplayName: ev.sender && ev.sender.name ? ev.sender.name : ev.getSender(),
+ roomName: room ? room.name : '',
+ });
+
const ImageView = sdk.getComponent("elements.ImageView");
const params = {
src: httpUrl,
- name: name,
+ name: text,
};
Modal.createDialog(ImageView, params, "mx_Dialog_lightbox");
},
@@ -47,15 +56,11 @@ module.exports = React.createClass({
const BaseAvatar = sdk.getComponent("avatars.BaseAvatar");
const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId());
- const name = _t('%(senderDisplayName)s changed the avatar for %(roomName)s', {
- senderDisplayName: senderDisplayName,
- roomName: room ? room.name : '',
- });
if (!ev.getContent().url || ev.getContent().url.trim().length === 0) {
return (
- { _t('%(senderDisplayName)s removed the room avatar.', {senderDisplayName: senderDisplayName}) }
+ { _t('%(senderDisplayName)s removed the room avatar.', {senderDisplayName}) }
);
}
@@ -75,8 +80,8 @@ module.exports = React.createClass({
{
'img': () =>
-
+ onClick={this.onAvatarClick}>
+
,
})
}
From 423a74c99cc94ba8af2cdc2be999925883530310 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Thu, 8 Aug 2019 20:21:53 +0100
Subject: [PATCH 2/4] Clean up implementation
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/components/views/avatars/BaseAvatar.js | 7 ++++++-
.../views/messages/RoomAvatarEvent.js | 19 +++++++------------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/components/views/avatars/BaseAvatar.js b/src/components/views/avatars/BaseAvatar.js
index 80f5c43d0c..8e13f89d2d 100644
--- a/src/components/views/avatars/BaseAvatar.js
+++ b/src/components/views/avatars/BaseAvatar.js
@@ -1,6 +1,7 @@
/*
Copyright 2015, 2016 OpenMarket Ltd
Copyright 2018 New Vector Ltd
+Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -19,7 +20,6 @@ import React from 'react';
import PropTypes from 'prop-types';
import { MatrixClient } from 'matrix-js-sdk';
import AvatarLogic from '../../../Avatar';
-import sdk from '../../../index';
import SettingsStore from "../../../settings/SettingsStore";
import AccessibleButton from '../elements/AccessibleButton';
@@ -121,6 +121,10 @@ module.exports = React.createClass({
);
urls.push(defaultImageUrl); // lowest priority
}
+
+ // deduplicate URLs
+ urls = Array.from(new Set(urls));
+
return {
imageUrls: urls,
defaultImageUrl: defaultImageUrl,
@@ -129,6 +133,7 @@ module.exports = React.createClass({
},
onError: function(ev) {
+ console.log("onError");
const nextIndex = this.state.urlsIndex + 1;
if (nextIndex < this.state.imageUrls.length) {
// try the next one
diff --git a/src/components/views/messages/RoomAvatarEvent.js b/src/components/views/messages/RoomAvatarEvent.js
index 72d0d1926a..17460ee183 100644
--- a/src/components/views/messages/RoomAvatarEvent.js
+++ b/src/components/views/messages/RoomAvatarEvent.js
@@ -1,5 +1,6 @@
/*
Copyright 2017 Vector Creations Ltd
+Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -17,7 +18,6 @@ limitations under the License.
import React from 'react';
import PropTypes from 'prop-types';
import MatrixClientPeg from '../../../MatrixClientPeg';
-import { ContentRepo } from 'matrix-js-sdk';
import { _t } from '../../../languageHandler';
import sdk from '../../../index';
import Modal from '../../../Modal';
@@ -53,9 +53,7 @@ module.exports = React.createClass({
render: function() {
const ev = this.props.mxEvent;
const senderDisplayName = ev.sender && ev.sender.name ? ev.sender.name : ev.getSender();
- const BaseAvatar = sdk.getComponent("avatars.BaseAvatar");
-
- const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId());
+ const RoomAvatar = sdk.getComponent("avatars.RoomAvatar");
if (!ev.getContent().url || ev.getContent().url.trim().length === 0) {
return (
@@ -65,13 +63,10 @@ module.exports = React.createClass({
);
}
- const url = ContentRepo.getHttpUriForMxc(
- MatrixClientPeg.get().getHomeserverUrl(),
- ev.getContent().url,
- Math.ceil(14 * window.devicePixelRatio),
- Math.ceil(14 * window.devicePixelRatio),
- 'crop',
- );
+ const room = MatrixClientPeg.get().getRoom(ev.getRoomId());
+ const oobData = {
+ avatarUrl: ev.getContent().url,
+ };
return (
@@ -81,7 +76,7 @@ module.exports = React.createClass({
'img': () =>
-
+
,
})
}
From ee3542453e309d91eb4e8f50487e0c1290f599d7 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Fri, 9 Aug 2019 11:31:04 +0100
Subject: [PATCH 3/4] Fix RoomAvatarEvent historic fallback
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/components/views/avatars/BaseAvatar.js | 1 -
src/components/views/messages/RoomAvatarEvent.js | 4 +++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/components/views/avatars/BaseAvatar.js b/src/components/views/avatars/BaseAvatar.js
index 8e13f89d2d..afc6faa18d 100644
--- a/src/components/views/avatars/BaseAvatar.js
+++ b/src/components/views/avatars/BaseAvatar.js
@@ -133,7 +133,6 @@ module.exports = React.createClass({
},
onError: function(ev) {
- console.log("onError");
const nextIndex = this.state.urlsIndex + 1;
if (nextIndex < this.state.imageUrls.length) {
// try the next one
diff --git a/src/components/views/messages/RoomAvatarEvent.js b/src/components/views/messages/RoomAvatarEvent.js
index 17460ee183..207a385b92 100644
--- a/src/components/views/messages/RoomAvatarEvent.js
+++ b/src/components/views/messages/RoomAvatarEvent.js
@@ -64,8 +64,10 @@ module.exports = React.createClass({
}
const room = MatrixClientPeg.get().getRoom(ev.getRoomId());
+ // Provide all arguments to RoomAvatar via oobData because the avatar is historic
const oobData = {
avatarUrl: ev.getContent().url,
+ name: room ? room.name : "",
};
return (
@@ -76,7 +78,7 @@ module.exports = React.createClass({
'img': () =>
-
+
,
})
}
From 438eba1c46dfa2dd69b0c0b56cf7400bdefdeafd Mon Sep 17 00:00:00 2001
From: Travis Ralston
Date: Mon, 12 Aug 2019 14:14:17 -0600
Subject: [PATCH 4/4] Fix alignment of add email/phone number inputs in
settings
---
res/css/views/settings/tabs/user/_GeneralUserSettingsTab.scss | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/res/css/views/settings/tabs/user/_GeneralUserSettingsTab.scss b/res/css/views/settings/tabs/user/_GeneralUserSettingsTab.scss
index 091c98ffb8..3b330f2c30 100644
--- a/res/css/views/settings/tabs/user/_GeneralUserSettingsTab.scss
+++ b/res/css/views/settings/tabs/user/_GeneralUserSettingsTab.scss
@@ -23,8 +23,8 @@ limitations under the License.
margin-top: 0;
}
-.mx_GeneralUserSettingsTab_accountSection > .mx_EmailAddresses,
-.mx_GeneralUserSettingsTab_accountSection > .mx_PhoneNumbers,
+.mx_GeneralUserSettingsTab_accountSection .mx_EmailAddresses,
+.mx_GeneralUserSettingsTab_accountSection .mx_PhoneNumbers,
.mx_GeneralUserSettingsTab_languageInput {
margin-right: 100px; // Align with the other fields on the page
}