From 98a6dd88e33151dee55b576ecb4406b4116c4393 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Tue, 2 Jun 2020 13:53:13 +0100 Subject: [PATCH 01/17] Upgrade matrix-js-sdk to 6.2.0-rc.1 --- package.json | 6 ++++-- yarn.lock | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index c0e489515e..fa4535935b 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "is-ip": "^2.0.0", "linkifyjs": "^2.1.6", "lodash": "^4.17.14", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop", + "matrix-js-sdk": "6.2.0-rc.1", "minimist": "^1.2.0", "pako": "^1.0.5", "parse5": "^5.1.1", @@ -164,7 +164,9 @@ "testMatch": [ "/test/**/*-test.js" ], - "setupFiles": ["jest-canvas-mock"], + "setupFiles": [ + "jest-canvas-mock" + ], "setupFilesAfterEnv": [ "/test/setupTests.js" ], diff --git a/yarn.lock b/yarn.lock index d9423fc5ab..3a3fca0fcc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5801,9 +5801,10 @@ mathml-tag-names@^2.0.1: resolved "https://registry.yarnpkg.com/mathml-tag-names/-/mathml-tag-names-2.1.3.tgz#4ddadd67308e780cf16a47685878ee27b736a0a3" integrity sha512-APMBEanjybaPzUrfqU0IMU5I0AswKMH7k8OTLs0vvV4KZpExkTkY87nR/zpbuTPj+gARop7aGUbl11pnDfW6xg== -"matrix-js-sdk@github:matrix-org/matrix-js-sdk#develop": - version "6.1.0" - resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/a4a7097c103da42075f2c70e070fd01fa6fb0d48" +matrix-js-sdk@6.2.0-rc.1: + version "6.2.0-rc.1" + resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-6.2.0-rc.1.tgz#467cc1dc9f59a95573da8bc5f9eeef76e5fdd792" + integrity sha512-bAg8muF2xP6kXLpbDSSWRTvkxV7QoF8H14RmMxAu4IWuQg/WB7BFcG7JZyGwyOD7gmPVPMIw8mHXGkUuh1mKtA== dependencies: "@babel/runtime" "^7.8.3" another-json "^0.2.0" From 5880297055435c4e5e737cc84793bc0e40254001 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Tue, 2 Jun 2020 13:59:10 +0100 Subject: [PATCH 02/17] Prepare changelog for v2.7.0-rc.1 --- CHANGELOG.md | 164 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5515f1015..9e8b21ca4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,167 @@ +Changes in [2.7.0-rc.1](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v2.7.0-rc.1) (2020-06-02) +============================================================================================================= +[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v2.6.1...v2.7.0-rc.1) + + * Upgrade to JS SDK 6.2.0-rc.1 + * Update from Weblate + [\#4683](https://github.com/matrix-org/matrix-react-sdk/pull/4683) + * Make auth argument in the register request compliant with r0.6.0 + [\#4347](https://github.com/matrix-org/matrix-react-sdk/pull/4347) + * Revert "Prevent PersistedElements overflowing scrolled areas" + [\#4682](https://github.com/matrix-org/matrix-react-sdk/pull/4682) + * Remove unused TagPanelButtons + [\#4680](https://github.com/matrix-org/matrix-react-sdk/pull/4680) + * Pass roomId to IRCTimelineProfileResizer + [\#4679](https://github.com/matrix-org/matrix-react-sdk/pull/4679) + * Remove logging to console for irc name resize + [\#4678](https://github.com/matrix-org/matrix-react-sdk/pull/4678) + * Use arrow functions instead of binding `this` + [\#4677](https://github.com/matrix-org/matrix-react-sdk/pull/4677) + * Increase specificity of compact layout selectors + [\#4675](https://github.com/matrix-org/matrix-react-sdk/pull/4675) + * Create and use stylised checkboxes + [\#4665](https://github.com/matrix-org/matrix-react-sdk/pull/4665) + * useIRCLayout moved to props + [\#4676](https://github.com/matrix-org/matrix-react-sdk/pull/4676) + * Fix paste image to upload + [\#4674](https://github.com/matrix-org/matrix-react-sdk/pull/4674) + * Fix FilePanel and NotificationsPanel regression + [\#4647](https://github.com/matrix-org/matrix-react-sdk/pull/4647) + * Allow deferring of Update Toast until the next morning + [\#4669](https://github.com/matrix-org/matrix-react-sdk/pull/4669) + * Give contextual feedback for manual update check instead of banner + [\#4668](https://github.com/matrix-org/matrix-react-sdk/pull/4668) + * Dialog wrap title instead of taking same space as the close/cancel button + [\#4659](https://github.com/matrix-org/matrix-react-sdk/pull/4659) + * Update Modular hosting link + [\#4627](https://github.com/matrix-org/matrix-react-sdk/pull/4627) + * Fix field placeholder regression + [\#4663](https://github.com/matrix-org/matrix-react-sdk/pull/4663) + * Fix/document a number of UIA oddities + [\#4667](https://github.com/matrix-org/matrix-react-sdk/pull/4667) + * Stop copy icon repeating weirdly + [\#4662](https://github.com/matrix-org/matrix-react-sdk/pull/4662) + * Try and fix the Notifier race + [\#4661](https://github.com/matrix-org/matrix-react-sdk/pull/4661) + * set the client's pickle key if the platform can store one + [\#4657](https://github.com/matrix-org/matrix-react-sdk/pull/4657) + * Migrate Banners to Toasts + [\#4624](https://github.com/matrix-org/matrix-react-sdk/pull/4624) + * Move Appearance tab to ts + [\#4658](https://github.com/matrix-org/matrix-react-sdk/pull/4658) + * Fix room alias lookup vs peeking race condition + [\#4606](https://github.com/matrix-org/matrix-react-sdk/pull/4606) + * Fix encryption icon miss-alignment + [\#4651](https://github.com/matrix-org/matrix-react-sdk/pull/4651) + * Fix sublist sizing regression + [\#4649](https://github.com/matrix-org/matrix-react-sdk/pull/4649) + * Fix lines overflowing room list width + [\#4650](https://github.com/matrix-org/matrix-react-sdk/pull/4650) + * Remove the keyshare dialog + [\#4648](https://github.com/matrix-org/matrix-react-sdk/pull/4648) + * Update badge counts in new room list as needed + [\#4654](https://github.com/matrix-org/matrix-react-sdk/pull/4654) + * EventIndex: Handle invalid m.room.redaction events correctly. + [\#4653](https://github.com/matrix-org/matrix-react-sdk/pull/4653) + * EventIndex: Print out the checkpoint if there was an error during a crawl + [\#4652](https://github.com/matrix-org/matrix-react-sdk/pull/4652) + * Move Field to Typescript + [\#4635](https://github.com/matrix-org/matrix-react-sdk/pull/4635) + * Use connection error to detect network problem + [\#4646](https://github.com/matrix-org/matrix-react-sdk/pull/4646) + * Revert default font size to 15px + [\#4641](https://github.com/matrix-org/matrix-react-sdk/pull/4641) + * Add logging when room join fails + [\#4645](https://github.com/matrix-org/matrix-react-sdk/pull/4645) + * Remove EncryptedEventDialog + [\#4644](https://github.com/matrix-org/matrix-react-sdk/pull/4644) + * Migrate Toasts to Typescript and to granular priority system + [\#4618](https://github.com/matrix-org/matrix-react-sdk/pull/4618) + * Update Crypto Store Too New copy + [\#4632](https://github.com/matrix-org/matrix-react-sdk/pull/4632) + * MemberAvatar should not have its own letter fallback, it should use + BaseAvatar + [\#4643](https://github.com/matrix-org/matrix-react-sdk/pull/4643) + * Fix media upload issues with abort and status bar + [\#4630](https://github.com/matrix-org/matrix-react-sdk/pull/4630) + * fix viewGroup to actually show the group if possible + [\#4633](https://github.com/matrix-org/matrix-react-sdk/pull/4633) + * Update confirm passphrase copy + [\#4634](https://github.com/matrix-org/matrix-react-sdk/pull/4634) + * Improve accessibility of the emoji picker + [\#4636](https://github.com/matrix-org/matrix-react-sdk/pull/4636) + * Fix Emoji Picker footer being too small if text overflows + [\#4631](https://github.com/matrix-org/matrix-react-sdk/pull/4631) + * Improve style of toasts to match Figma + [\#4613](https://github.com/matrix-org/matrix-react-sdk/pull/4613) + * Iterate toast count indicator more logically + [\#4620](https://github.com/matrix-org/matrix-react-sdk/pull/4620) + * Fix reacting to redactions + [\#4626](https://github.com/matrix-org/matrix-react-sdk/pull/4626) + * Fix sentMessageAndIsAlone by dispatching `message_sent` more consistently + [\#4628](https://github.com/matrix-org/matrix-react-sdk/pull/4628) + * Update from Weblate + [\#4640](https://github.com/matrix-org/matrix-react-sdk/pull/4640) + * Replace `alias` with `address` in copy for consistency + [\#4402](https://github.com/matrix-org/matrix-react-sdk/pull/4402) + * Convert MatrixClientPeg to TypeScript + [\#4638](https://github.com/matrix-org/matrix-react-sdk/pull/4638) + * Fix BaseAvatar wrongly retrying urls + [\#4629](https://github.com/matrix-org/matrix-react-sdk/pull/4629) + * Fix event highlights not being updated to reflect edits + [\#4637](https://github.com/matrix-org/matrix-react-sdk/pull/4637) + * Calculate badges in the new room list more reliably + [\#4625](https://github.com/matrix-org/matrix-react-sdk/pull/4625) + * Transition BaseAvatar to hooks + [\#4101](https://github.com/matrix-org/matrix-react-sdk/pull/4101) + * Convert BasePlatform and BaseEventIndexManager to Typescript + [\#4614](https://github.com/matrix-org/matrix-react-sdk/pull/4614) + * Fix: Tag_DM is not defined + [\#4619](https://github.com/matrix-org/matrix-react-sdk/pull/4619) + * Fix visibility of message timestamps + [\#4615](https://github.com/matrix-org/matrix-react-sdk/pull/4615) + * Rewrite the room list store + [\#4253](https://github.com/matrix-org/matrix-react-sdk/pull/4253) + * Update code style to mention switch statements + [\#4610](https://github.com/matrix-org/matrix-react-sdk/pull/4610) + * Fix key backup restore with SSSS + [\#4612](https://github.com/matrix-org/matrix-react-sdk/pull/4612) + * Handle null tokens in the crawler loop. + [\#4608](https://github.com/matrix-org/matrix-react-sdk/pull/4608) + * Font scaling settings and slider + [\#4424](https://github.com/matrix-org/matrix-react-sdk/pull/4424) + * Prevent PersistedElements overflowing scrolled areas + [\#4494](https://github.com/matrix-org/matrix-react-sdk/pull/4494) + * IRC ui layout + [\#4531](https://github.com/matrix-org/matrix-react-sdk/pull/4531) + * Remove SSSS key upgrade check from rageshake + [\#4607](https://github.com/matrix-org/matrix-react-sdk/pull/4607) + * Label the create room button better than "Add room" + [\#4603](https://github.com/matrix-org/matrix-react-sdk/pull/4603) + * Convert the dispatcher to TypeScript + [\#4593](https://github.com/matrix-org/matrix-react-sdk/pull/4593) + * Consolidate password/passphrase fields into a component & add dynamic colour + to progress + [\#4599](https://github.com/matrix-org/matrix-react-sdk/pull/4599) + * UserView, show Welcome page in the mid panel instead of empty space + [\#4590](https://github.com/matrix-org/matrix-react-sdk/pull/4590) + * Update from Weblate + [\#4601](https://github.com/matrix-org/matrix-react-sdk/pull/4601) + * Make email auth component fail better if server claims email isn't validated + [\#4600](https://github.com/matrix-org/matrix-react-sdk/pull/4600) + * Add new keyboard shortcuts for jump to unread and upload file + [\#4588](https://github.com/matrix-org/matrix-react-sdk/pull/4588) + * accept and linkify local domains like those from mDNS + [\#4594](https://github.com/matrix-org/matrix-react-sdk/pull/4594) + * Revert "ImageView make clicking off it easier" + [\#4586](https://github.com/matrix-org/matrix-react-sdk/pull/4586) + * wrap node-qrcode in a React FC and use it for ShareDialog + [\#4394](https://github.com/matrix-org/matrix-react-sdk/pull/4394) + * Pass screenAfterLogin through SSO in the callback url + [\#4585](https://github.com/matrix-org/matrix-react-sdk/pull/4585) + * Remove debugging that causes email addresses to load forever + [\#4597](https://github.com/matrix-org/matrix-react-sdk/pull/4597) + Changes in [2.6.1](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v2.6.1) (2020-05-22) =================================================================================================== [Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v2.6.0...v2.6.1) From 039c42dc0978bd4ec0d218c35a776035fe9ed5d4 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Tue, 2 Jun 2020 13:59:10 +0100 Subject: [PATCH 03/17] v2.7.0-rc.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fa4535935b..b22356bbc0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-react-sdk", - "version": "2.6.1", + "version": "2.7.0-rc.1", "description": "SDK for matrix.org using React", "author": "matrix.org", "repository": { From c31cfbd3eb9da78557c6de49071b96c7a952d482 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Tue, 2 Jun 2020 14:37:47 +0100 Subject: [PATCH 04/17] Prepare changelog for v2.7.0-rc.2 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e8b21ca4b..bba4a836cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +Changes in [2.7.0-rc.2](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v2.7.0-rc.2) (2020-06-02) +============================================================================================================= +[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v2.7.0-rc.1...v2.7.0-rc.2) + + * Rewire the Sticker button to be an Emoji Picker + [\#3747](https://github.com/matrix-org/matrix-react-sdk/pull/3747) + Changes in [2.7.0-rc.1](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v2.7.0-rc.1) (2020-06-02) ============================================================================================================= [Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v2.6.1...v2.7.0-rc.1) From ec35445bf0522eff8cae37d70e5c6115741a2c7b Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Tue, 2 Jun 2020 14:37:47 +0100 Subject: [PATCH 05/17] v2.7.0-rc.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b22356bbc0..c1bcfb31b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-react-sdk", - "version": "2.7.0-rc.1", + "version": "2.7.0-rc.2", "description": "SDK for matrix.org using React", "author": "matrix.org", "repository": { From 5bc756cba14b91f0096ac1625fa1934d505a4ca1 Mon Sep 17 00:00:00 2001 From: Jorik Schellekens Date: Wed, 3 Jun 2020 16:48:05 +0100 Subject: [PATCH 06/17] Fix checkbox bleed --- res/css/views/elements/_AddressSelector.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/res/css/views/elements/_AddressSelector.scss b/res/css/views/elements/_AddressSelector.scss index dd78fcc0f0..087504390c 100644 --- a/res/css/views/elements/_AddressSelector.scss +++ b/res/css/views/elements/_AddressSelector.scss @@ -23,6 +23,7 @@ limitations under the License. border-radius: 3px; border: solid 1px $accent-color; cursor: pointer; + z-index: 1; } .mx_AddressSelector.mx_AddressSelector_empty { From 84d81ff09b683b47a551e88c7f8c502a5ba67cd1 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 2 Jun 2020 16:26:07 +0100 Subject: [PATCH 07/17] Fix login loop where the sso flow returns to `#/login` due to fragmentAfterLogin going back to `#/login` and https://github.com/vector-im/riot-web/issues/11643 Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/BasePlatform.ts | 16 +++++++++++----- src/Lifecycle.js | 17 ++++++++++------- src/components/structures/MatrixChat.tsx | 5 ++++- src/components/structures/auth/SoftLogout.js | 9 +++++---- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/BasePlatform.ts b/src/BasePlatform.ts index c5f58f7f0c..98c37a86ce 100644 --- a/src/BasePlatform.ts +++ b/src/BasePlatform.ts @@ -25,6 +25,9 @@ import {CheckUpdatesPayload} from "./dispatcher/payloads/CheckUpdatesPayload"; import {Action} from "./dispatcher/actions"; import {hideToast as hideUpdateToast} from "./toasts/UpdateToast"; +export const HS_URL_LS_KEY = "mx_hs_url"; +export const IS_URL_LS_KEY = "mx_is_url"; + export enum UpdateCheckStatus { Checking = "CHECKING", Error = "ERROR", @@ -47,6 +50,7 @@ export default abstract class BasePlatform { constructor() { dis.register(this.onAction); + this.startUpdateCheck = this.startUpdateCheck.bind(this); } protected onAction = (payload: ActionPayload) => { @@ -217,11 +221,9 @@ export default abstract class BasePlatform { setLanguage(preferredLangs: string[]) {} - getSSOCallbackUrl(hsUrl: string, isUrl: string, fragmentAfterLogin: string): URL { + getSSOCallbackUrl(fragmentAfterLogin: string): URL { const url = new URL(window.location.href); url.hash = fragmentAfterLogin || ""; - url.searchParams.set("homeserver", hsUrl); - url.searchParams.set("identityServer", isUrl); return url; } @@ -232,8 +234,12 @@ export default abstract class BasePlatform { * @param {string} fragmentAfterLogin the hash to pass to the app during sso callback. */ startSingleSignOn(mxClient: MatrixClient, loginType: "sso" | "cas", fragmentAfterLogin: string) { - const callbackUrl = this.getSSOCallbackUrl(mxClient.getHomeserverUrl(), mxClient.getIdentityServerUrl(), - fragmentAfterLogin); + // persist hs url and is url for when the user is returned to the app with the login token + localStorage.setItem(HS_URL_LS_KEY, mxClient.getHomeserverUrl()); + if (mxClient.getIdentityServerUrl()) { + localStorage.setItem(IS_URL_LS_KEY, mxClient.getIdentityServerUrl()); + } + const callbackUrl = this.getSSOCallbackUrl(fragmentAfterLogin); window.location.href = mxClient.getSsoLoginUrl(callbackUrl.toString(), loginType); // redirect to SSO } diff --git a/src/Lifecycle.js b/src/Lifecycle.js index 0494628472..58720682bb 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -41,6 +41,7 @@ import {IntegrationManagers} from "./integrations/IntegrationManagers"; import {Mjolnir} from "./mjolnir/Mjolnir"; import DeviceListener from "./DeviceListener"; import {Jitsi} from "./widgets/Jitsi"; +import {HS_URL_LS_KEY, IS_URL_LS_KEY} from "./BasePlatform"; /** * Called at startup, to attempt to build a logged-in Matrix session. It tries @@ -163,14 +164,16 @@ export function attemptTokenLogin(queryParams, defaultDeviceDisplayName) { return Promise.resolve(false); } - if (!queryParams.homeserver) { + const homeserver = localStorage.getItem(HS_URL_LS_KEY); + const identityServer = localStorage.getItem(IS_URL_LS_KEY); + if (!homeserver) { console.warn("Cannot log in with token: can't determine HS URL to use"); return Promise.resolve(false); } return sendLoginRequest( - queryParams.homeserver, - queryParams.identityServer, + homeserver, + identityServer, "m.login.token", { token: queryParams.loginToken, initial_device_display_name: defaultDeviceDisplayName, @@ -256,8 +259,8 @@ function _registerAsGuest(hsUrl, isUrl, defaultDeviceDisplayName) { * @returns {Object} Information about the session - see implementation for variables. */ export function getLocalStorageSessionVars() { - const hsUrl = localStorage.getItem("mx_hs_url"); - const isUrl = localStorage.getItem("mx_is_url"); + const hsUrl = localStorage.getItem(HS_URL_LS_KEY); + const isUrl = localStorage.getItem(IS_URL_LS_KEY); const accessToken = localStorage.getItem("mx_access_token"); const userId = localStorage.getItem("mx_user_id"); const deviceId = localStorage.getItem("mx_device_id"); @@ -486,9 +489,9 @@ function _showStorageEvictedDialog() { class AbortLoginAndRebuildStorage extends Error { } function _persistCredentialsToLocalStorage(credentials) { - localStorage.setItem("mx_hs_url", credentials.homeserverUrl); + localStorage.setItem(HS_URL_LS_KEY, credentials.homeserverUrl); if (credentials.identityServerUrl) { - localStorage.setItem("mx_is_url", credentials.identityServerUrl); + localStorage.setItem(IS_URL_LS_KEY, credentials.identityServerUrl); } localStorage.setItem("mx_user_id", credentials.userId); localStorage.setItem("mx_access_token", credentials.accessToken); diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index 058a7ba50b..9527d65eea 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -1942,7 +1942,10 @@ export default class MatrixChat extends React.PureComponent { // console.log(`Rendering MatrixChat with view ${this.state.view}`); let fragmentAfterLogin = ""; - if (this.props.initialScreenAfterLogin) { + if (this.props.initialScreenAfterLogin && + // XXX: workaround for https://github.com/vector-im/riot-web/issues/11643 causing a login-loop + !["welcome", "login", "register"].includes(this.props.initialScreenAfterLogin.screen) + ) { fragmentAfterLogin = `/${this.props.initialScreenAfterLogin.screen}`; } diff --git a/src/components/structures/auth/SoftLogout.js b/src/components/structures/auth/SoftLogout.js index 5d9f868f85..58a3fc3c15 100644 --- a/src/components/structures/auth/SoftLogout.js +++ b/src/components/structures/auth/SoftLogout.js @@ -25,6 +25,7 @@ import {MatrixClientPeg} from "../../../MatrixClientPeg"; import {sendLoginRequest} from "../../../Login"; import AuthPage from "../../views/auth/AuthPage"; import SSOButton from "../../views/elements/SSOButton"; +import {HS_URL_LS_KEY, IS_URL_LS_KEY} from "../../../BasePlatform"; const LOGIN_VIEW = { LOADING: 1, @@ -43,7 +44,7 @@ const FLOWS_TO_VIEWS = { export default class SoftLogout extends React.Component { static propTypes = { // Query parameters from MatrixChat - realQueryParams: PropTypes.object, // {homeserver, identityServer, loginToken} + realQueryParams: PropTypes.object, // {loginToken} // Called when the SSO login completes onTokenLoginCompleted: PropTypes.func, @@ -90,7 +91,7 @@ export default class SoftLogout extends React.Component { async _initLogin() { const queryParams = this.props.realQueryParams; - const hasAllParams = queryParams && queryParams['homeserver'] && queryParams['loginToken']; + const hasAllParams = queryParams && queryParams['loginToken']; if (hasAllParams) { this.setState({loginView: LOGIN_VIEW.LOADING}); this.trySsoLogin(); @@ -157,8 +158,8 @@ export default class SoftLogout extends React.Component { async trySsoLogin() { this.setState({busy: true}); - const hsUrl = this.props.realQueryParams['homeserver']; - const isUrl = this.props.realQueryParams['identityServer'] || MatrixClientPeg.get().getIdentityServerUrl(); + const hsUrl = localStorage.getItem(HS_URL_LS_KEY); + const isUrl = localStorage.getItem(IS_URL_LS_KEY) || MatrixClientPeg.get().getIdentityServerUrl(); const loginType = "m.login.token"; const loginParams = { token: this.props.realQueryParams['loginToken'], From 096045a037ab5a5f4b8d834bd85ab74dc1c8f08d Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 3 Jun 2020 20:23:01 +0100 Subject: [PATCH 08/17] change names of consts for clarity Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/BasePlatform.ts | 8 ++++---- src/Lifecycle.js | 14 +++++++------- src/components/structures/auth/SoftLogout.js | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/BasePlatform.ts b/src/BasePlatform.ts index 98c37a86ce..520c3fbe46 100644 --- a/src/BasePlatform.ts +++ b/src/BasePlatform.ts @@ -25,8 +25,8 @@ import {CheckUpdatesPayload} from "./dispatcher/payloads/CheckUpdatesPayload"; import {Action} from "./dispatcher/actions"; import {hideToast as hideUpdateToast} from "./toasts/UpdateToast"; -export const HS_URL_LS_KEY = "mx_hs_url"; -export const IS_URL_LS_KEY = "mx_is_url"; +export const HOMESERVER_URL_KEY = "mx_hs_url"; +export const ID_SERVER_URL_KEY = "mx_is_url"; export enum UpdateCheckStatus { Checking = "CHECKING", @@ -235,9 +235,9 @@ export default abstract class BasePlatform { */ startSingleSignOn(mxClient: MatrixClient, loginType: "sso" | "cas", fragmentAfterLogin: string) { // persist hs url and is url for when the user is returned to the app with the login token - localStorage.setItem(HS_URL_LS_KEY, mxClient.getHomeserverUrl()); + localStorage.setItem(HOMESERVER_URL_KEY, mxClient.getHomeserverUrl()); if (mxClient.getIdentityServerUrl()) { - localStorage.setItem(IS_URL_LS_KEY, mxClient.getIdentityServerUrl()); + localStorage.setItem(ID_SERVER_URL_KEY, mxClient.getIdentityServerUrl()); } const callbackUrl = this.getSSOCallbackUrl(fragmentAfterLogin); window.location.href = mxClient.getSsoLoginUrl(callbackUrl.toString(), loginType); // redirect to SSO diff --git a/src/Lifecycle.js b/src/Lifecycle.js index 58720682bb..d018ea99aa 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -41,7 +41,7 @@ import {IntegrationManagers} from "./integrations/IntegrationManagers"; import {Mjolnir} from "./mjolnir/Mjolnir"; import DeviceListener from "./DeviceListener"; import {Jitsi} from "./widgets/Jitsi"; -import {HS_URL_LS_KEY, IS_URL_LS_KEY} from "./BasePlatform"; +import {HOMESERVER_URL_KEY, ID_SERVER_URL_KEY} from "./BasePlatform"; /** * Called at startup, to attempt to build a logged-in Matrix session. It tries @@ -164,8 +164,8 @@ export function attemptTokenLogin(queryParams, defaultDeviceDisplayName) { return Promise.resolve(false); } - const homeserver = localStorage.getItem(HS_URL_LS_KEY); - const identityServer = localStorage.getItem(IS_URL_LS_KEY); + const homeserver = localStorage.getItem(HOMESERVER_URL_KEY); + const identityServer = localStorage.getItem(ID_SERVER_URL_KEY); if (!homeserver) { console.warn("Cannot log in with token: can't determine HS URL to use"); return Promise.resolve(false); @@ -259,8 +259,8 @@ function _registerAsGuest(hsUrl, isUrl, defaultDeviceDisplayName) { * @returns {Object} Information about the session - see implementation for variables. */ export function getLocalStorageSessionVars() { - const hsUrl = localStorage.getItem(HS_URL_LS_KEY); - const isUrl = localStorage.getItem(IS_URL_LS_KEY); + const hsUrl = localStorage.getItem(HOMESERVER_URL_KEY); + const isUrl = localStorage.getItem(ID_SERVER_URL_KEY); const accessToken = localStorage.getItem("mx_access_token"); const userId = localStorage.getItem("mx_user_id"); const deviceId = localStorage.getItem("mx_device_id"); @@ -489,9 +489,9 @@ function _showStorageEvictedDialog() { class AbortLoginAndRebuildStorage extends Error { } function _persistCredentialsToLocalStorage(credentials) { - localStorage.setItem(HS_URL_LS_KEY, credentials.homeserverUrl); + localStorage.setItem(HOMESERVER_URL_KEY, credentials.homeserverUrl); if (credentials.identityServerUrl) { - localStorage.setItem(IS_URL_LS_KEY, credentials.identityServerUrl); + localStorage.setItem(ID_SERVER_URL_KEY, credentials.identityServerUrl); } localStorage.setItem("mx_user_id", credentials.userId); localStorage.setItem("mx_access_token", credentials.accessToken); diff --git a/src/components/structures/auth/SoftLogout.js b/src/components/structures/auth/SoftLogout.js index 58a3fc3c15..a2824b63a3 100644 --- a/src/components/structures/auth/SoftLogout.js +++ b/src/components/structures/auth/SoftLogout.js @@ -25,7 +25,7 @@ import {MatrixClientPeg} from "../../../MatrixClientPeg"; import {sendLoginRequest} from "../../../Login"; import AuthPage from "../../views/auth/AuthPage"; import SSOButton from "../../views/elements/SSOButton"; -import {HS_URL_LS_KEY, IS_URL_LS_KEY} from "../../../BasePlatform"; +import {HOMESERVER_URL_KEY, ID_SERVER_URL_KEY} from "../../../BasePlatform"; const LOGIN_VIEW = { LOADING: 1, @@ -158,8 +158,8 @@ export default class SoftLogout extends React.Component { async trySsoLogin() { this.setState({busy: true}); - const hsUrl = localStorage.getItem(HS_URL_LS_KEY); - const isUrl = localStorage.getItem(IS_URL_LS_KEY) || MatrixClientPeg.get().getIdentityServerUrl(); + const hsUrl = localStorage.getItem(HOMESERVER_URL_KEY); + const isUrl = localStorage.getItem(ID_SERVER_URL_KEY) || MatrixClientPeg.get().getIdentityServerUrl(); const loginType = "m.login.token"; const loginParams = { token: this.props.realQueryParams['loginToken'], From 993a545cd2d431dfd0fbcfd3a1769b518d414456 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 4 Jun 2020 09:50:19 +0100 Subject: [PATCH 09/17] Profile settings should never show a disambiguated display name Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/settings/ProfileSettings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/views/settings/ProfileSettings.js b/src/components/views/settings/ProfileSettings.js index 23ab60423a..5dbdcd4901 100644 --- a/src/components/views/settings/ProfileSettings.js +++ b/src/components/views/settings/ProfileSettings.js @@ -40,8 +40,8 @@ export default class ProfileSettings extends React.Component { if (avatarUrl) avatarUrl = client.mxcUrlToHttp(avatarUrl, 96, 96, 'crop', false); this.state = { userId: user.userId, - originalDisplayName: user.displayName, - displayName: user.displayName, + originalDisplayName: user.rawDisplayName, + displayName: user.rawDisplayName, originalAvatarUrl: avatarUrl, avatarUrl: avatarUrl, avatarFile: null, From 07e0cab4a840c86b55accdf30a2ff0886de2bf5c Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 4 Jun 2020 12:49:33 +0200 Subject: [PATCH 10/17] When trying to restore a keyback that has its key in 4S, check if 4S will be readable If the account data for the 4S key is cleared or lost somehow, don't attempt to read the key and ask for the passphrase/recovery key instead, as doing so would trigger another bootstrap from the restore key backup dialog, overwriting the existing key backup. --- .../views/dialogs/keybackup/RestoreKeyBackupDialog.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js b/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js index a27853db56..dd34dfbbf0 100644 --- a/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js +++ b/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js @@ -227,8 +227,10 @@ export default class RestoreKeyBackupDialog extends React.PureComponent { loadError: null, }); try { - const backupInfo = await MatrixClientPeg.get().getKeyBackupVersion(); - const backupKeyStored = await MatrixClientPeg.get().isKeyBackupKeyStored(); + const cli = MatrixClientPeg.get(); + const backupInfo = await cli.getKeyBackupVersion(); + const has4S = await cli.hasSecretStorageKey(); + const backupKeyStored = has4S && await cli.isKeyBackupKeyStored(); this.setState({ backupInfo, backupKeyStored, From ca69a9d7bb58fd9891e72b64d1b007e5981726fe Mon Sep 17 00:00:00 2001 From: Jorik Schellekens Date: Wed, 3 Jun 2020 16:48:05 +0100 Subject: [PATCH 11/17] Fix checkbox bleed --- res/css/views/elements/_AddressSelector.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/res/css/views/elements/_AddressSelector.scss b/res/css/views/elements/_AddressSelector.scss index dd78fcc0f0..087504390c 100644 --- a/res/css/views/elements/_AddressSelector.scss +++ b/res/css/views/elements/_AddressSelector.scss @@ -23,6 +23,7 @@ limitations under the License. border-radius: 3px; border: solid 1px $accent-color; cursor: pointer; + z-index: 1; } .mx_AddressSelector.mx_AddressSelector_empty { From 40cabd258921d33da62e5a7b94edcc1ff646209d Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 4 Jun 2020 12:49:33 +0200 Subject: [PATCH 12/17] When trying to restore a keyback that has its key in 4S, check if 4S will be readable If the account data for the 4S key is cleared or lost somehow, don't attempt to read the key and ask for the passphrase/recovery key instead, as doing so would trigger another bootstrap from the restore key backup dialog, overwriting the existing key backup. --- .../views/dialogs/keybackup/RestoreKeyBackupDialog.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js b/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js index a16202ed93..829a4f102e 100644 --- a/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js +++ b/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js @@ -243,8 +243,10 @@ export default class RestoreKeyBackupDialog extends React.PureComponent { loadError: null, }); try { - const backupInfo = await MatrixClientPeg.get().getKeyBackupVersion(); - const backupKeyStored = await MatrixClientPeg.get().isKeyBackupKeyStored(); + const cli = MatrixClientPeg.get(); + const backupInfo = await cli.getKeyBackupVersion(); + const has4S = await cli.hasSecretStorageKey(); + const backupKeyStored = has4S && await cli.isKeyBackupKeyStored(); this.setState({ backupInfo, backupKeyStored, From 6d81337d924574ba23e82aff4c370424f1196e46 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 4 Jun 2020 13:10:45 +0100 Subject: [PATCH 13/17] Tidy up continuation algorithm and make it work for hidden profile change events Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/MessagePanel.js | 64 ++++++++++------------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index 2069255ea2..d11fee6360 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -34,6 +34,30 @@ import IRCTimelineProfileResizer from "../views/elements/IRCTimelineProfileResiz const CONTINUATION_MAX_INTERVAL = 5 * 60 * 1000; // 5 minutes const continuedTypes = ['m.sticker', 'm.room.message']; +// check if there is a previous event and it has the same sender as this event +// and the types are the same/is in continuedTypes and the time between them is <= CONTINUATION_MAX_INTERVAL +function shouldFormContinuation(prevEvent, mxEvent) { + // sanity check inputs + if (!prevEvent || !prevEvent.sender || !mxEvent.sender) return false; + // check if within the max continuation period + if (mxEvent.getTs() - prevEvent.getTs() > CONTINUATION_MAX_INTERVAL) return false; + + // Some events should appear as continuations from previous events of different types. + if (mxEvent.getType() !== prevEvent.getType() && + (!continuedTypes.includes(mxEvent.getType()) || + !continuedTypes.includes(prevEvent.getType()))) return false; + + // Check if the sender is the same and hasn't changed their displayname/avatar between these events + if (mxEvent.sender.userId !== prevEvent.sender.userId || + mxEvent.sender.name !== prevEvent.sender.name || + mxEvent.sender.getMxcAvatarUrl() !== prevEvent.sender.getMxcAvatarUrl()) return false; + + // if we don't have tile for previous event then it was shown by showHiddenEvents and has no SenderProfile + if (!haveTileForEvent(prevEvent)) return false; + + return true; +} + const isMembershipChange = (e) => e.getType() === 'm.room.member' || e.getType() === 'm.room.third_party_invite'; /* (almost) stateless UI component which builds the event tiles in the room timeline. @@ -515,39 +539,6 @@ export default class MessagePanel extends React.Component { const isEditing = this.props.editState && this.props.editState.getEvent().getId() === mxEv.getId(); - // is this a continuation of the previous message? - let continuation = false; - - // Some events should appear as continuations from previous events of - // different types. - - const eventTypeContinues = - prevEvent !== null && - continuedTypes.includes(mxEv.getType()) && - continuedTypes.includes(prevEvent.getType()); - - // if there is a previous event and it has the same sender as this event - // and the types are the same/is in continuedTypes and the time between them is <= CONTINUATION_MAX_INTERVAL - if (prevEvent !== null && prevEvent.sender && mxEv.sender && mxEv.sender.userId === prevEvent.sender.userId && - // if we don't have tile for previous event then it was shown by showHiddenEvents and has no SenderProfile - haveTileForEvent(prevEvent) && (mxEv.getType() === prevEvent.getType() || eventTypeContinues) && - (mxEv.getTs() - prevEvent.getTs() <= CONTINUATION_MAX_INTERVAL)) { - continuation = true; - } - -/* - // Work out if this is still a continuation, as we are now showing commands - // and /me messages with their own little avatar. The case of a change of - // event type (commands) is handled above, but we need to handle the /me - // messages seperately as they have a msgtype of 'm.emote' but are classed - // as normal messages - if (prevEvent !== null && prevEvent.sender && mxEv.sender - && mxEv.sender.userId === prevEvent.sender.userId - && mxEv.getType() == prevEvent.getType() - && prevEvent.getContent().msgtype === 'm.emote') { - continuation = false; - } -*/ // local echoes have a fake date, which could even be yesterday. Treat them // as 'today' for the date separators. @@ -559,12 +550,15 @@ export default class MessagePanel extends React.Component { } // do we need a date separator since the last event? - if (this._wantsDateSeparator(prevEvent, eventDate)) { + const wantsDateSeparator = this._wantsDateSeparator(prevEvent, eventDate); + if (wantsDateSeparator) { const dateSeparator =
  • ; ret.push(dateSeparator); - continuation = false; } + // is this a continuation of the previous message? + const continuation = !wantsDateSeparator && shouldFormContinuation(prevEvent, mxEv); + const eventId = mxEv.getId(); const highlight = (eventId === this.props.highlightedEventId); From 07a12a73eec1115c1fe2cd193ffe4965d2536bc6 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Thu, 4 Jun 2020 15:06:40 +0100 Subject: [PATCH 14/17] Upgrade matrix-js-sdk to 6.2.0 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index c1bcfb31b7..d42e555968 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "is-ip": "^2.0.0", "linkifyjs": "^2.1.6", "lodash": "^4.17.14", - "matrix-js-sdk": "6.2.0-rc.1", + "matrix-js-sdk": "6.2.0", "minimist": "^1.2.0", "pako": "^1.0.5", "parse5": "^5.1.1", diff --git a/yarn.lock b/yarn.lock index 3a3fca0fcc..1ed5f82369 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5801,10 +5801,10 @@ mathml-tag-names@^2.0.1: resolved "https://registry.yarnpkg.com/mathml-tag-names/-/mathml-tag-names-2.1.3.tgz#4ddadd67308e780cf16a47685878ee27b736a0a3" integrity sha512-APMBEanjybaPzUrfqU0IMU5I0AswKMH7k8OTLs0vvV4KZpExkTkY87nR/zpbuTPj+gARop7aGUbl11pnDfW6xg== -matrix-js-sdk@6.2.0-rc.1: - version "6.2.0-rc.1" - resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-6.2.0-rc.1.tgz#467cc1dc9f59a95573da8bc5f9eeef76e5fdd792" - integrity sha512-bAg8muF2xP6kXLpbDSSWRTvkxV7QoF8H14RmMxAu4IWuQg/WB7BFcG7JZyGwyOD7gmPVPMIw8mHXGkUuh1mKtA== +matrix-js-sdk@6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-6.2.0.tgz#b1aa6f23858ab3ee4b66be25d3e854f6e287d36b" + integrity sha512-dpx1EuJ98HtqE2YUeliTe9xjMOJlicJGRXa06Gr8RAL6WJM7buPgodOk0tRs461LzeilxmymqcGaB4og6o9RxA== dependencies: "@babel/runtime" "^7.8.3" another-json "^0.2.0" From 5aff8f79150e7801540a28e90d7f5983e27bd8b1 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Thu, 4 Jun 2020 15:12:23 +0100 Subject: [PATCH 15/17] Prepare changelog for v2.7.0 --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bba4a836cf..89b20de919 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +Changes in [2.7.0](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v2.7.0) (2020-06-04) +=================================================================================================== +[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v2.7.0-rc.2...v2.7.0) + + * Prevent (double) 4S bootstrap from RestoreKeyBackupDialog + [\#4703](https://github.com/matrix-org/matrix-react-sdk/pull/4703) + * Fix checkbox bleed + [\#4702](https://github.com/matrix-org/matrix-react-sdk/pull/4702) + * Fix login loop where the sso flow returns to `#/login` to release + [\#4693](https://github.com/matrix-org/matrix-react-sdk/pull/4693) + Changes in [2.7.0-rc.2](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v2.7.0-rc.2) (2020-06-02) ============================================================================================================= [Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v2.7.0-rc.1...v2.7.0-rc.2) From 65e59fd7085cd4b3b03c1ef83fd841b37874ffb0 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Thu, 4 Jun 2020 15:12:24 +0100 Subject: [PATCH 16/17] v2.7.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d42e555968..bc009f3c15 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-react-sdk", - "version": "2.7.0-rc.2", + "version": "2.7.0", "description": "SDK for matrix.org using React", "author": "matrix.org", "repository": { From 3c73930e9a4a841d646a13002f9d5a154968f8fa Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Thu, 4 Jun 2020 15:14:34 +0100 Subject: [PATCH 17/17] Reset matrix-js-sdk back to develop branch --- package.json | 2 +- yarn.lock | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 74e9d818e8..7006c13f10 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "is-ip": "^2.0.0", "linkifyjs": "^2.1.6", "lodash": "^4.17.14", - "matrix-js-sdk": "6.2.0", + "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop", "minimist": "^1.2.0", "pako": "^1.0.5", "parse5": "^5.1.1", diff --git a/yarn.lock b/yarn.lock index 3964a89843..adc880ffa5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5801,10 +5801,9 @@ mathml-tag-names@^2.0.1: resolved "https://registry.yarnpkg.com/mathml-tag-names/-/mathml-tag-names-2.1.3.tgz#4ddadd67308e780cf16a47685878ee27b736a0a3" integrity sha512-APMBEanjybaPzUrfqU0IMU5I0AswKMH7k8OTLs0vvV4KZpExkTkY87nR/zpbuTPj+gARop7aGUbl11pnDfW6xg== -matrix-js-sdk@6.2.0: +"matrix-js-sdk@github:matrix-org/matrix-js-sdk#develop": version "6.2.0" - resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-6.2.0.tgz#b1aa6f23858ab3ee4b66be25d3e854f6e287d36b" - integrity sha512-dpx1EuJ98HtqE2YUeliTe9xjMOJlicJGRXa06Gr8RAL6WJM7buPgodOk0tRs461LzeilxmymqcGaB4og6o9RxA== + resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/ef1d5e3d765bc4dc133c0637434c2ca9941ff97b" dependencies: "@babel/runtime" "^7.8.3" another-json "^0.2.0"