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 01/10] 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': () =>
@@ -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 03/10] 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 242f23c7531faf3d42faad567fca7b9ce8057484 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Fri, 9 Aug 2019 18:08:17 +0100
Subject: [PATCH 04/10] RegistrationForm: the Fields are controlled, fix
default values
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/components/views/auth/RegistrationForm.js | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/src/components/views/auth/RegistrationForm.js b/src/components/views/auth/RegistrationForm.js
index cd3dab12ac..f3b9640e16 100644
--- a/src/components/views/auth/RegistrationForm.js
+++ b/src/components/views/auth/RegistrationForm.js
@@ -2,6 +2,7 @@
Copyright 2015, 2016 OpenMarket Ltd
Copyright 2017 Vector Creations Ltd
Copyright 2018, 2019 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.
@@ -69,10 +70,10 @@ module.exports = React.createClass({
fieldValid: {},
// The ISO2 country code selected in the phone number entry
phoneCountry: this.props.defaultPhoneCountry,
- username: "",
- email: "",
- phoneNumber: "",
- password: "",
+ username: this.props.defaultUsername || "",
+ email: this.props.defaultEmail || "",
+ phoneNumber: this.props.defaultPhoneNumber || "",
+ password: this.props.defaultPassword || "",
passwordConfirm: "",
passwordComplexity: null,
passwordSafe: false,
@@ -90,7 +91,7 @@ module.exports = React.createClass({
}
const self = this;
- if (this.state.email == '') {
+ if (this.state.email === '') {
const haveIs = Boolean(this.props.serverConfig.isUrl);
let desc;
@@ -455,7 +456,6 @@ module.exports = React.createClass({
ref={field => this[FIELD_EMAIL] = field}
type="text"
label={emailPlaceholder}
- defaultValue={this.props.defaultEmail}
value={this.state.email}
onChange={this.onEmailChange}
onValidate={this.onEmailValidate}
@@ -469,7 +469,6 @@ module.exports = React.createClass({
ref={field => this[FIELD_PASSWORD] = field}
type="password"
label={_t("Password")}
- defaultValue={this.props.defaultPassword}
value={this.state.password}
onChange={this.onPasswordChange}
onValidate={this.onPasswordValidate}
@@ -483,7 +482,6 @@ module.exports = React.createClass({
ref={field => this[FIELD_PASSWORD_CONFIRM] = field}
type="password"
label={_t("Confirm")}
- defaultValue={this.props.defaultPassword}
value={this.state.passwordConfirm}
onChange={this.onPasswordConfirmChange}
onValidate={this.onPasswordConfirmValidate}
@@ -512,7 +510,6 @@ module.exports = React.createClass({
ref={field => this[FIELD_PHONE_NUMBER] = field}
type="text"
label={phoneLabel}
- defaultValue={this.props.defaultPhoneNumber}
value={this.state.phoneNumber}
prefix={phoneCountry}
onChange={this.onPhoneNumberChange}
@@ -528,7 +525,6 @@ module.exports = React.createClass({
type="text"
autoFocus={true}
label={_t("Username")}
- defaultValue={this.props.defaultUsername}
value={this.state.username}
onChange={this.onUsernameChange}
onValidate={this.onUsernameValidate}
From 3e08bf6ecb5e5298ddb31fcc9afd4a06282800b7 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Sun, 11 Aug 2019 03:34:12 +0100
Subject: [PATCH 05/10] Deduplicate code in ModularServerConfig by extending
ServerConfig
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
.../views/auth/ModularServerConfig.js | 76 +------------------
1 file changed, 3 insertions(+), 73 deletions(-)
diff --git a/src/components/views/auth/ModularServerConfig.js b/src/components/views/auth/ModularServerConfig.js
index b5af58adf1..ff8d88f738 100644
--- a/src/components/views/auth/ModularServerConfig.js
+++ b/src/components/views/auth/ModularServerConfig.js
@@ -15,13 +15,13 @@ limitations under the License.
*/
import React from 'react';
-import PropTypes from 'prop-types';
import sdk from '../../../index';
import { _t } from '../../../languageHandler';
import {ValidatedServerConfig} from "../../../utils/AutoDiscoveryUtils";
import SdkConfig from "../../../SdkConfig";
import AutoDiscoveryUtils from "../../../utils/AutoDiscoveryUtils";
import * as ServerType from '../../views/auth/ServerTypeSelector';
+import ServerConfig from "./ServerConfig";
const MODULAR_URL = 'https://modular.im/?utm_source=riot-web&utm_medium=web&utm_campaign=riot-web-authentication';
@@ -33,49 +33,8 @@ const MODULAR_URL = 'https://modular.im/?utm_source=riot-web&utm_medium=web&utm_
* This is a variant of ServerConfig with only the HS field and different body
* text that is specific to the Modular case.
*/
-export default class ModularServerConfig extends React.PureComponent {
- static propTypes = {
- onServerConfigChange: PropTypes.func,
-
- // The current configuration that the user is expecting to change.
- serverConfig: PropTypes.instanceOf(ValidatedServerConfig).isRequired,
-
- delayTimeMs: PropTypes.number, // time to wait before invoking onChanged
-
- // Called after the component calls onServerConfigChange
- onAfterSubmit: PropTypes.func,
-
- // Optional text for the submit button. If falsey, no button will be shown.
- submitText: PropTypes.string,
-
- // Optional class for the submit button. Only applies if the submit button
- // is to be rendered.
- submitClass: PropTypes.string,
- };
-
- static defaultProps = {
- onServerConfigChange: function() {},
- customHsUrl: "",
- delayTimeMs: 0,
- };
-
- constructor(props) {
- super(props);
-
- this.state = {
- busy: false,
- errorText: "",
- hsUrl: props.serverConfig.hsUrl,
- isUrl: props.serverConfig.isUrl,
- };
- }
-
- componentWillReceiveProps(newProps) {
- if (newProps.serverConfig.hsUrl === this.state.hsUrl &&
- newProps.serverConfig.isUrl === this.state.isUrl) return;
-
- this.validateAndApplyServer(newProps.serverConfig.hsUrl, newProps.serverConfig.isUrl);
- }
+export default class ModularServerConfig extends ServerConfig {
+ static propTypes = ServerConfig.propTypes;
async validateAndApplyServer(hsUrl, isUrl) {
// Always try and use the defaults first
@@ -120,35 +79,6 @@ export default class ModularServerConfig extends React.PureComponent {
return this.validateAndApplyServer(this.state.hsUrl, ServerType.TYPES.PREMIUM.identityServerUrl);
}
- onHomeserverBlur = (ev) => {
- this._hsTimeoutId = this._waitThenInvoke(this._hsTimeoutId, () => {
- this.validateServer();
- });
- };
-
- onHomeserverChange = (ev) => {
- const hsUrl = ev.target.value;
- this.setState({ hsUrl });
- };
-
- onSubmit = async (ev) => {
- ev.preventDefault();
- ev.stopPropagation();
- const result = await this.validateServer();
- if (!result) return; // Do not continue.
-
- if (this.props.onAfterSubmit) {
- this.props.onAfterSubmit();
- }
- };
-
- _waitThenInvoke(existingTimeoutId, fn) {
- if (existingTimeoutId) {
- clearTimeout(existingTimeoutId);
- }
- return setTimeout(fn.bind(this), this.props.delayTimeMs);
- }
-
render() {
const Field = sdk.getComponent('elements.Field');
const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
From 916af736ad2445ad21168c7ae16fe10a8139693a Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Sun, 11 Aug 2019 03:43:34 +0100
Subject: [PATCH 06/10] Consolidate Themes into ThemeController. Remove
hardcoded themes in view
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
.../settings/tabs/user/GeneralUserSettingsTab.js | 7 +++++--
src/settings/controllers/ThemeController.js | 12 +++++++-----
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js b/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js
index a9c010b6b4..5fbc8deb35 100644
--- a/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js
+++ b/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js
@@ -1,6 +1,7 @@
/*
Copyright 2019 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
+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.
@@ -26,6 +27,7 @@ import LanguageDropdown from "../../../elements/LanguageDropdown";
import AccessibleButton from "../../../elements/AccessibleButton";
import DeactivateAccountDialog from "../../../dialogs/DeactivateAccountDialog";
import PropTypes from "prop-types";
+import {SUPPORTED_THEMES} from "../../../../../settings/controllers/ThemeController";
const PlatformPeg = require("../../../../../PlatformPeg");
const MatrixClientPeg = require("../../../../../MatrixClientPeg");
const sdk = require('../../../../..');
@@ -160,8 +162,9 @@ export default class GeneralUserSettingsTab extends React.Component {
{_t("Theme")}
-
-
+ {Object.entries(SUPPORTED_THEMES).map(([theme, text]) => {
+ return ;
+ })}
diff --git a/src/settings/controllers/ThemeController.js b/src/settings/controllers/ThemeController.js
index 615fc4c192..fd35f79622 100644
--- a/src/settings/controllers/ThemeController.js
+++ b/src/settings/controllers/ThemeController.js
@@ -1,5 +1,6 @@
/*
Copyright 2019 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.
@@ -15,16 +16,17 @@ limitations under the License.
*/
import SettingController from "./SettingController";
+import {_td} from "../../languageHandler";
-const SUPPORTED_THEMES = [
- "light",
- "dark",
-];
+export const SUPPORTED_THEMES = {
+ "light": _td("Light theme"),
+ "dark": _td("Dark theme"),
+};
export default class ThemeController extends SettingController {
getValueOverride(level, roomId, calculatedValue, calculatedAtLevel) {
// Override in case some no longer supported theme is stored here
- if (!SUPPORTED_THEMES.includes(calculatedValue)) {
+ if (!SUPPORTED_THEMES[calculatedValue]) {
return "light";
}
From 7bdac85a2a9f353f784320bf241378616a1a0323 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Mon, 12 Aug 2019 14:24:12 +0100
Subject: [PATCH 07/10] Break themes out into a separate file
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
.../tabs/user/GeneralUserSettingsTab.js | 4 ++--
src/i18n/strings/en_EN.json | 4 ++--
src/settings/controllers/ThemeController.js | 11 +++------
src/themes.js | 24 +++++++++++++++++++
4 files changed, 31 insertions(+), 12 deletions(-)
create mode 100644 src/themes.js
diff --git a/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js b/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js
index 5fbc8deb35..4326a4f39e 100644
--- a/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js
+++ b/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js
@@ -27,7 +27,7 @@ import LanguageDropdown from "../../../elements/LanguageDropdown";
import AccessibleButton from "../../../elements/AccessibleButton";
import DeactivateAccountDialog from "../../../dialogs/DeactivateAccountDialog";
import PropTypes from "prop-types";
-import {SUPPORTED_THEMES} from "../../../../../settings/controllers/ThemeController";
+import {THEMES} from "../../../../../themes";
const PlatformPeg = require("../../../../../PlatformPeg");
const MatrixClientPeg = require("../../../../../MatrixClientPeg");
const sdk = require('../../../../..');
@@ -162,7 +162,7 @@ export default class GeneralUserSettingsTab extends React.Component {