From cdd1ad1e2f210a77b5922e1784e39d5bed0751e7 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 2 Oct 2019 16:26:52 +0200 Subject: [PATCH 1/9] submit form when pressing enter --- src/components/views/dialogs/CreateRoomDialog.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/views/dialogs/CreateRoomDialog.js b/src/components/views/dialogs/CreateRoomDialog.js index 8e267da5d1..026c60235a 100644 --- a/src/components/views/dialogs/CreateRoomDialog.js +++ b/src/components/views/dialogs/CreateRoomDialog.js @@ -73,6 +73,14 @@ export default createReactClass({ this._detailsRef.removeEventListener("toggle", this.onDetailsToggled); }, + _onKeyDown: function(event) { + if (event.key === "Enter") { + this.onOk(); + event.preventDefault(); + event.stopPropagation(); + } + }, + onOk: async function() { const activeElement = document.activeElement; if (activeElement) { @@ -176,7 +184,7 @@ export default createReactClass({ -
+
this._nameFieldRef = ref} label={ _t('Name') } onChange={this.onNameChange} onValidate={this.onNameValidate} value={this.state.name} className="mx_CreateRoomDialog_name" /> From 48b80449376f41e69fe8434a5ada96d9dc4a1ee2 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 7 Oct 2019 17:43:17 +0200 Subject: [PATCH 2/9] don't try to get id server domain when not asked to bind --- src/AddThreepid.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/AddThreepid.js b/src/AddThreepid.js index 8f19815210..dde0fbcbc9 100644 --- a/src/AddThreepid.js +++ b/src/AddThreepid.js @@ -20,6 +20,10 @@ import MatrixClientPeg from './MatrixClientPeg'; import { _t } from './languageHandler'; import IdentityAuthClient from './IdentityAuthClient'; +function getIdServerDomain() { + return MatrixClientPeg.get().idBaseUrl.split("://")[1]; +} + /** * Allows a user to add a third party identifier to their homeserver and, * optionally, the identity servers. @@ -155,7 +159,6 @@ export default class AddThreepid { * the request failed. */ async checkEmailLinkClicked() { - const identityServerDomain = MatrixClientPeg.get().idBaseUrl.split("://")[1]; try { if (await MatrixClientPeg.get().doesServerSupportSeparateAddAndBind()) { if (this.bind) { @@ -164,7 +167,7 @@ export default class AddThreepid { await MatrixClientPeg.get().bindThreePid({ sid: this.sessionId, client_secret: this.clientSecret, - id_server: identityServerDomain, + id_server: getIdServerDomain(), id_access_token: identityAccessToken, }); } else { @@ -177,7 +180,7 @@ export default class AddThreepid { await MatrixClientPeg.get().addThreePid({ sid: this.sessionId, client_secret: this.clientSecret, - id_server: identityServerDomain, + id_server: getIdServerDomain(), }, this.bind); } } catch (err) { From 040bc5e1576f369f07ec29ad9c1c0497202d28ff Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 7 Oct 2019 17:43:51 +0200 Subject: [PATCH 3/9] show dialog when server says e-mail hasn't been verified yet as it's confusing to have nothing happen at all when clicking continue straight away. --- .../views/settings/account/EmailAddresses.js | 10 ++++++++-- src/i18n/strings/en_EN.json | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/views/settings/account/EmailAddresses.js b/src/components/views/settings/account/EmailAddresses.js index 30fc805f6d..e50039d0b6 100644 --- a/src/components/views/settings/account/EmailAddresses.js +++ b/src/components/views/settings/account/EmailAddresses.js @@ -193,8 +193,14 @@ export default class EmailAddresses extends React.Component { this.props.onEmailsChange(emails); }).catch((err) => { this.setState({continueDisabled: false}); - if (err.errcode !== 'M_THREEPID_AUTH_FAILED') { - const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + if (err.errcode === 'M_THREEPID_AUTH_FAILED') { + Modal.createTrackedDialog("Email hasn't been verified yet", "", ErrorDialog, { + title: _t("Your email address hasn't been verified yet"), + description: _t("Click the link in the email you received to verify, " + + "and then click continue again."), + }); + } else { console.error("Unable to verify email address: " + err); Modal.createTrackedDialog('Unable to verify email address', '', ErrorDialog, { title: _t("Unable to verify email address."), diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index fc094f48f6..74502444b8 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -759,6 +759,8 @@ "Invalid Email Address": "Invalid Email Address", "This doesn't appear to be a valid email address": "This doesn't appear to be a valid email address", "Unable to add email address": "Unable to add email address", + "Your e-mail address hasn't been verified yet": "Your e-mail address hasn't been verified yet", + "Click the link in the e-mail you received to verify, and then click continue again.": "Click the link in the e-mail you received to verify, and then click continue again.", "Add": "Add", "We've sent you an email to verify your address. Please follow the instructions there and then click the button below.": "We've sent you an email to verify your address. Please follow the instructions there and then click the button below.", "Email Address": "Email Address", From 978866ea960635fb125f45311c1dbd0b2183a0ad Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 8 Oct 2019 08:43:40 +0200 Subject: [PATCH 4/9] dont assume id server when verifying phone numbers either --- src/AddThreepid.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/AddThreepid.js b/src/AddThreepid.js index dde0fbcbc9..f0781e26e9 100644 --- a/src/AddThreepid.js +++ b/src/AddThreepid.js @@ -224,13 +224,12 @@ export default class AddThreepid { throw result; } - const identityServerDomain = MatrixClientPeg.get().idBaseUrl.split("://")[1]; if (await MatrixClientPeg.get().doesServerSupportSeparateAddAndBind()) { if (this.bind) { await MatrixClientPeg.get().bindThreePid({ sid: this.sessionId, client_secret: this.clientSecret, - id_server: identityServerDomain, + id_server: getIdServerDomain(), id_access_token: await authClient.getAccessToken(), }); } else { @@ -243,7 +242,7 @@ export default class AddThreepid { await MatrixClientPeg.get().addThreePid({ sid: this.sessionId, client_secret: this.clientSecret, - id_server: identityServerDomain, + id_server: getIdServerDomain(), }, this.bind); } } From 1ab19be46c38f7f885ea568ff730031dad390778 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 8 Oct 2019 08:50:17 +0200 Subject: [PATCH 5/9] also show dialog here unsure why this code seems duplicated? --- .../views/settings/discovery/EmailAddresses.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/views/settings/discovery/EmailAddresses.js b/src/components/views/settings/discovery/EmailAddresses.js index a4fcd605fc..b83701cbed 100644 --- a/src/components/views/settings/discovery/EmailAddresses.js +++ b/src/components/views/settings/discovery/EmailAddresses.js @@ -171,8 +171,14 @@ export class EmailAddress extends React.Component { }); } catch (err) { this.setState({ continueDisabled: false }); - if (err.errcode !== 'M_THREEPID_AUTH_FAILED') { - const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + if (err.errcode === 'M_THREEPID_AUTH_FAILED') { + Modal.createTrackedDialog("E-mail hasn't been verified yet", "", ErrorDialog, { + title: _t("Your email address hasn't been verified yet"), + description: _t("Click the link in the email you received to verify, " + + "and then click continue again."), + }); + } else { console.error("Unable to verify email address: " + err); Modal.createTrackedDialog('Unable to verify email address', '', ErrorDialog, { title: _t("Unable to verify email address."), From cbeb45abd368a99cfee12722eb76e19927a91e98 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 8 Oct 2019 08:56:34 +0200 Subject: [PATCH 6/9] update i18n --- src/i18n/strings/en_EN.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 74502444b8..ba0fbf628e 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -740,6 +740,8 @@ "Who can read history?": "Who can read history?", "Unable to revoke sharing for email address": "Unable to revoke sharing for email address", "Unable to share email address": "Unable to share email address", + "Your email address hasn't been verified yet": "Your email address hasn't been verified yet", + "Click the link in the email you received to verify, and then click continue again.": "Click the link in the email you received to verify, and then click continue again.", "Unable to verify email address.": "Unable to verify email address.", "Verify the link in your inbox": "Verify the link in your inbox", "Complete": "Complete", @@ -759,8 +761,6 @@ "Invalid Email Address": "Invalid Email Address", "This doesn't appear to be a valid email address": "This doesn't appear to be a valid email address", "Unable to add email address": "Unable to add email address", - "Your e-mail address hasn't been verified yet": "Your e-mail address hasn't been verified yet", - "Click the link in the e-mail you received to verify, and then click continue again.": "Click the link in the e-mail you received to verify, and then click continue again.", "Add": "Add", "We've sent you an email to verify your address. Please follow the instructions there and then click the button below.": "We've sent you an email to verify your address. Please follow the instructions there and then click the button below.", "Email Address": "Email Address", From 91d593cb7113e57b892152d17f604597209b586d Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 8 Oct 2019 14:11:11 +0200 Subject: [PATCH 7/9] watch emoticon autoreplace setting --- src/components/views/rooms/BasicMessageComposer.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/views/rooms/BasicMessageComposer.js b/src/components/views/rooms/BasicMessageComposer.js index 4ec43d8af2..92c2ae29e6 100644 --- a/src/components/views/rooms/BasicMessageComposer.js +++ b/src/components/views/rooms/BasicMessageComposer.js @@ -90,6 +90,7 @@ export default class BasicMessageEditor extends React.Component { this._modifiedFlag = false; this._isIMEComposing = false; this._hasTextSelected = false; + this._emoticonSettingHandle = null; } _replaceEmoticon = (caretPosition, inputType, diff) => { @@ -437,18 +438,25 @@ export default class BasicMessageEditor extends React.Component { this.setState({completionIndex}); } + _configureEmoticonAutoReplace() { + const shouldReplace = SettingsStore.getValue('MessageComposerInput.autoReplaceEmoji'); + this.props.model.setTransformCallback(shouldReplace ? this._replaceEmoticon : null); + } + componentWillUnmount() { this._editorRef.removeEventListener("input", this._onInput, true); this._editorRef.removeEventListener("compositionstart", this._onCompositionStart, true); this._editorRef.removeEventListener("compositionend", this._onCompositionEnd, true); + SettingsStore.unwatchSetting(this._emoticonSettingHandle); } componentDidMount() { const model = this.props.model; model.setUpdateCallback(this._updateEditorState); - if (SettingsStore.getValue('MessageComposerInput.autoReplaceEmoji')) { - model.setTransformCallback(this._replaceEmoticon); - } + this._emoticonSettingHandle = SettingsStore.watchSetting('MessageComposerInput.autoReplaceEmoji', null, () => { + this._configureEmoticonAutoReplace(); + }); + this._configureEmoticonAutoReplace(); const partCreator = model.partCreator; // TODO: does this allow us to get rid of EditorStateTransfer? // not really, but we could not serialize the parts, and just change the autoCompleter From 538c3795d8ed8154a6527142ed8647a0f4f7eb68 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 8 Oct 2019 14:29:03 +0100 Subject: [PATCH 8/9] Allow cyclic objects in console logs This fixes a bug in rageshake handling that would throw an error if you log a cyclic object, which can be convenient during development. --- src/rageshake/rageshake.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/rageshake/rageshake.js b/src/rageshake/rageshake.js index c848be6c2b..d61956c925 100644 --- a/src/rageshake/rageshake.js +++ b/src/rageshake/rageshake.js @@ -1,6 +1,7 @@ /* Copyright 2017 OpenMarket Ltd Copyright 2018 New Vector Ltd +Copyright 2019 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -76,8 +77,22 @@ class ConsoleLogger { args = args.map((arg) => { if (arg instanceof Error) { return arg.message + (arg.stack ? `\n${arg.stack}` : ''); - } else if (typeof(arg) === 'object') { - return JSON.stringify(arg); + } else if (typeof (arg) === 'object') { + try { + return JSON.stringify(arg); + } catch (e) { + // In development, it can be useful to log complex cyclic + // objects to the console for inspection. This is fine for + // the console, but default `stringify` can't handle that. + // We workaround this by using a special replacer function + // to only log values of the root object and avoid cycles. + return JSON.stringify(arg, (key, value) => { + if (key && typeof value === "object") { + return ""; + } + return value; + }); + } } else { return arg; } From 8c8b1430e48560ff8571370358057c0ab041964e Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 8 Oct 2019 18:39:35 +0200 Subject: [PATCH 9/9] fix spelling --- src/components/views/settings/account/EmailAddresses.js | 2 +- src/components/views/settings/discovery/EmailAddresses.js | 2 +- src/i18n/strings/en_EN.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/views/settings/account/EmailAddresses.js b/src/components/views/settings/account/EmailAddresses.js index e50039d0b6..382d2ee93b 100644 --- a/src/components/views/settings/account/EmailAddresses.js +++ b/src/components/views/settings/account/EmailAddresses.js @@ -197,7 +197,7 @@ export default class EmailAddresses extends React.Component { if (err.errcode === 'M_THREEPID_AUTH_FAILED') { Modal.createTrackedDialog("Email hasn't been verified yet", "", ErrorDialog, { title: _t("Your email address hasn't been verified yet"), - description: _t("Click the link in the email you received to verify, " + + description: _t("Click the link in the email you received to verify " + "and then click continue again."), }); } else { diff --git a/src/components/views/settings/discovery/EmailAddresses.js b/src/components/views/settings/discovery/EmailAddresses.js index b83701cbed..cc3d2d0dad 100644 --- a/src/components/views/settings/discovery/EmailAddresses.js +++ b/src/components/views/settings/discovery/EmailAddresses.js @@ -175,7 +175,7 @@ export class EmailAddress extends React.Component { if (err.errcode === 'M_THREEPID_AUTH_FAILED') { Modal.createTrackedDialog("E-mail hasn't been verified yet", "", ErrorDialog, { title: _t("Your email address hasn't been verified yet"), - description: _t("Click the link in the email you received to verify, " + + description: _t("Click the link in the email you received to verify " + "and then click continue again."), }); } else { diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index ba0fbf628e..31a26e6dcb 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -741,7 +741,7 @@ "Unable to revoke sharing for email address": "Unable to revoke sharing for email address", "Unable to share email address": "Unable to share email address", "Your email address hasn't been verified yet": "Your email address hasn't been verified yet", - "Click the link in the email you received to verify, and then click continue again.": "Click the link in the email you received to verify, and then click continue again.", + "Click the link in the email you received to verify and then click continue again.": "Click the link in the email you received to verify and then click continue again.", "Unable to verify email address.": "Unable to verify email address.", "Verify the link in your inbox": "Verify the link in your inbox", "Complete": "Complete",