From fd29c7353379808c718e4b24b5b7111126838e18 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Thu, 25 Mar 2021 12:12:55 +0000 Subject: [PATCH 01/11] Upgrade matrix-js-sdk to 9.10.0-rc.1 --- package.json | 2 +- yarn.lock | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index f8b4287197..45e83eb7b2 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "katex": "^0.12.0", "linkifyjs": "^2.1.9", "lodash": "^4.17.20", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop", + "matrix-js-sdk": "9.10.0-rc.1", "matrix-widget-api": "^0.1.0-beta.13", "minimist": "^1.2.5", "pako": "^2.0.3", diff --git a/yarn.lock b/yarn.lock index 58686248f7..cc79a1c61d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5587,9 +5587,10 @@ mathml-tag-names@^2.1.3: 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 "9.9.0" - resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/cd38fb9b4c349eb31feac14e806e710bf6431b72" +matrix-js-sdk@9.10.0-rc.1: + version "9.10.0-rc.1" + resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-9.10.0-rc.1.tgz#614f9429edc76348deb86ca436897c27d6849eb1" + integrity sha512-aJLXIKDcO4aGPU3dSfonYL2MXo2pz3USMqvFTmw5mfdVQKcgo8blHq6l/C8WEBk0r3oJfbG5E4O0HES5rdUSqA== dependencies: "@babel/runtime" "^7.12.5" another-json "^0.2.0" From d22dbeac6cd92d0e184b18c5501db6486b4d293c Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Thu, 25 Mar 2021 12:20:20 +0000 Subject: [PATCH 02/11] Prepare changelog for v3.17.0-rc.1 --- CHANGELOG.md | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38b1a2572f..15e09a2bb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,84 @@ +Changes in [3.17.0-rc.1](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v3.17.0-rc.1) (2021-03-25) +=============================================================================================================== +[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v3.16.0...v3.17.0-rc.1) + + * Upgrade to JS SDK 9.10.0-rc.1 + * Translations update from Weblate + [\#5788](https://github.com/matrix-org/matrix-react-sdk/pull/5788) + * Track next event [tile] over group boundaries + [\#5784](https://github.com/matrix-org/matrix-react-sdk/pull/5784) + * Fixing the minor UI issues in the email discovery + [\#5780](https://github.com/matrix-org/matrix-react-sdk/pull/5780) + * Don't overwrite callback with undefined if no customization provided + [\#5783](https://github.com/matrix-org/matrix-react-sdk/pull/5783) + * Fix redaction event list summaries breaking sender profiles + [\#5781](https://github.com/matrix-org/matrix-react-sdk/pull/5781) + * Fix CIDER formatting buttons on Safari + [\#5782](https://github.com/matrix-org/matrix-react-sdk/pull/5782) + * Improve discovery of rooms in a space + [\#5776](https://github.com/matrix-org/matrix-react-sdk/pull/5776) + * Spaces improve creation journeys + [\#5777](https://github.com/matrix-org/matrix-react-sdk/pull/5777) + * Make buttons in verify dialog respect the system font + [\#5778](https://github.com/matrix-org/matrix-react-sdk/pull/5778) + * Collapse redactions into an event list summary + [\#5728](https://github.com/matrix-org/matrix-react-sdk/pull/5728) + * Added invite option to room's context menu + [\#5648](https://github.com/matrix-org/matrix-react-sdk/pull/5648) + * Add an optional config option to make the welcome page the login page + [\#5658](https://github.com/matrix-org/matrix-react-sdk/pull/5658) + * Fix username showing instead of display name in Jitsi widgets + [\#5770](https://github.com/matrix-org/matrix-react-sdk/pull/5770) + * Convert a bunch more js-sdk imports to absolute paths + [\#5774](https://github.com/matrix-org/matrix-react-sdk/pull/5774) + * Remove forgotten rooms from the room list once forgotten + [\#5775](https://github.com/matrix-org/matrix-react-sdk/pull/5775) + * Log error when failing to list usermedia devices + [\#5771](https://github.com/matrix-org/matrix-react-sdk/pull/5771) + * Fix weird timeline jumps + [\#5772](https://github.com/matrix-org/matrix-react-sdk/pull/5772) + * Replace type declaration in Registration.tsx + [\#5773](https://github.com/matrix-org/matrix-react-sdk/pull/5773) + * Add possibility to delay rageshake persistence in app startup + [\#5767](https://github.com/matrix-org/matrix-react-sdk/pull/5767) + * Fix left panel resizing and lower min-width improving flexibility + [\#5764](https://github.com/matrix-org/matrix-react-sdk/pull/5764) + * Work around more cases where a rageshake server might not be present + [\#5766](https://github.com/matrix-org/matrix-react-sdk/pull/5766) + * Iterate space panel visually and functionally + [\#5761](https://github.com/matrix-org/matrix-react-sdk/pull/5761) + * Make some dispatches async + [\#5765](https://github.com/matrix-org/matrix-react-sdk/pull/5765) + * fix: make room directory correct when using a homeserver with explicit port + [\#5762](https://github.com/matrix-org/matrix-react-sdk/pull/5762) + * Hangup all calls on logout + [\#5756](https://github.com/matrix-org/matrix-react-sdk/pull/5756) + * Remove now-unused assets and CSS from CompleteSecurity step + [\#5757](https://github.com/matrix-org/matrix-react-sdk/pull/5757) + * Add details and summary to allowed HTML tags + [\#5760](https://github.com/matrix-org/matrix-react-sdk/pull/5760) + * Support a media handling customisation endpoint + [\#5714](https://github.com/matrix-org/matrix-react-sdk/pull/5714) + * Edit button on View Source dialog that takes you to devtools -> + SendCustomEvent + [\#5718](https://github.com/matrix-org/matrix-react-sdk/pull/5718) + * Show room alias in plain/formatted body + [\#5748](https://github.com/matrix-org/matrix-react-sdk/pull/5748) + * Allow pills on the beginning of a part string + [\#5754](https://github.com/matrix-org/matrix-react-sdk/pull/5754) + * [SK-3] Decorate easy components with replaceableComponent + [\#5734](https://github.com/matrix-org/matrix-react-sdk/pull/5734) + * Use fsync in reskindex to ensure file is written to disk + [\#5753](https://github.com/matrix-org/matrix-react-sdk/pull/5753) + * Remove unused common CSS classes + [\#5752](https://github.com/matrix-org/matrix-react-sdk/pull/5752) + * Rebuild space previews with new designs + [\#5751](https://github.com/matrix-org/matrix-react-sdk/pull/5751) + * Rework cross-signing login flow + [\#5727](https://github.com/matrix-org/matrix-react-sdk/pull/5727) + * Change read receipt drift to be non-fractional + [\#5745](https://github.com/matrix-org/matrix-react-sdk/pull/5745) + Changes in [3.16.0](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v3.16.0) (2021-03-15) ===================================================================================================== [Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v3.16.0-rc.2...v3.16.0) From 9e2edd701484ff6ee2b95dd1ebcc34ea95f56efa Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Thu, 25 Mar 2021 12:20:22 +0000 Subject: [PATCH 03/11] v3.17.0-rc.1 --- package.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 45e83eb7b2..0f742e2920 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-react-sdk", - "version": "3.16.0", + "version": "3.17.0-rc.1", "description": "SDK for matrix.org using React", "author": "matrix.org", "repository": { @@ -27,7 +27,7 @@ "matrix-gen-i18n": "scripts/gen-i18n.js", "matrix-prune-i18n": "scripts/prune-i18n.js" }, - "main": "./src/index.js", + "main": "./lib/index.js", "matrix_src_main": "./src/index.js", "matrix_lib_main": "./lib/index.js", "matrix_lib_typings": "./lib/index.d.ts", @@ -190,5 +190,6 @@ "transformIgnorePatterns": [ "/node_modules/(?!matrix-js-sdk).+$" ] - } + }, + "typings": "./lib/index.d.ts" } From 76965285dab0af5123e284841effee5ca834abae Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 25 Mar 2021 19:37:55 +0000 Subject: [PATCH 04/11] Fix edge case with redaction grouper messing up continuations --- src/components/structures/MessagePanel.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index 6d03c849c4..41a3015721 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -46,6 +46,9 @@ function shouldFormContinuation(prevEvent, mxEvent) { // check if within the max continuation period if (mxEvent.getTs() - prevEvent.getTs() > CONTINUATION_MAX_INTERVAL) return false; + // As we summarise redactions, do not continue a redacted event onto a non-redacted one and vice-versa + if (mxEvent.isRedacted() !== prevEvent.isRedacted()) return false; + // Some events should appear as continuations from previous events of different types. if (mxEvent.getType() !== prevEvent.getType() && (!continuedTypes.includes(mxEvent.getType()) || @@ -1125,7 +1128,7 @@ class RedactionGrouper { } getNewPrevEvent() { - return this.events[0]; + return this.events[this.events.length - 1]; } } From 4a883f2e88357b99c8339bbf85f4f5b7848cd8e5 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Fri, 26 Mar 2021 11:13:39 +0000 Subject: [PATCH 05/11] Tweak cross-signing copy This makes some Design-approved copy tweaks to the recent cross-signing flow changes. --- res/css/structures/_ToastContainer.scss | 6 +++++- src/components/structures/MatrixChat.tsx | 2 +- .../structures/auth/SetupEncryptionBody.js | 9 ++++----- .../views/dialogs/VerificationRequestDialog.js | 2 +- .../views/right_panel/EncryptionInfo.tsx | 2 +- src/components/views/toasts/GenericToast.tsx | 10 ++++++++-- .../views/toasts/VerificationRequestToast.tsx | 18 ++++++++++-------- src/i18n/strings/en_EN.json | 17 ++++++++--------- src/toasts/BulkUnverifiedSessionsToast.ts | 2 +- src/toasts/UnverifiedSessionToast.ts | 12 +++++------- 10 files changed, 44 insertions(+), 36 deletions(-) diff --git a/res/css/structures/_ToastContainer.scss b/res/css/structures/_ToastContainer.scss index c381668a6a..09f834a6e3 100644 --- a/res/css/structures/_ToastContainer.scss +++ b/res/css/structures/_ToastContainer.scss @@ -1,5 +1,5 @@ /* -Copyright 2019 The Matrix.org Foundation C.I.C. +Copyright 2019-2021 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. @@ -158,6 +158,10 @@ limitations under the License. } } + .mx_Toast_detail { + color: $secondary-fg-color; + } + .mx_Toast_deviceID { font-size: $font-10px; } diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index ac1842c7fd..fda4616b48 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -1556,7 +1556,7 @@ export default class MatrixChat extends React.PureComponent { } else if (request.pending) { ToastStore.sharedInstance().addOrReplaceToast({ key: 'verifreq_' + request.channel.transactionId, - title: request.isSelfVerification ? _t("Self-verification request") : _t("Verification Request"), + title: _t("Verification requested"), icon: "verification", props: {request}, component: sdk.getComponent("toasts.VerificationRequestToast"), diff --git a/src/components/structures/auth/SetupEncryptionBody.js b/src/components/structures/auth/SetupEncryptionBody.js index e246b9cbd0..803df19d00 100644 --- a/src/components/structures/auth/SetupEncryptionBody.js +++ b/src/components/structures/auth/SetupEncryptionBody.js @@ -155,15 +155,14 @@ export default class SetupEncryptionBody extends React.Component { let verifyButton; if (store.hasDevicesToVerifyAgainst) { verifyButton = - { _t("Verify with another session") } + { _t("Use another login") } ; } return (

{_t( - "Verify this login to access your encrypted messages and " + - "prove to others that this login is really you.", + "Verify your identity to access encrypted messages and prove your identity to others.", )}

@@ -205,8 +204,8 @@ export default class SetupEncryptionBody extends React.Component { return (

{_t( - "Without completing security on this session, it won’t have " + - "access to encrypted messages.", + "Without verifying, you won’t have access to all your messages " + + "and may appear as untrusted to others.", )}

= ({ let text: string; if (waitingForOtherParty) { if (isSelfVerification) { - text = _t("Waiting for you to accept on your other session…"); + text = _t("Accept on your other login…"); } else { text = _t("Waiting for %(displayName)s to accept…", { displayName: member.displayName || member.name || member.userId, diff --git a/src/components/views/toasts/GenericToast.tsx b/src/components/views/toasts/GenericToast.tsx index a9c64f1962..200c88875e 100644 --- a/src/components/views/toasts/GenericToast.tsx +++ b/src/components/views/toasts/GenericToast.tsx @@ -1,5 +1,5 @@ /* -Copyright 2020 The Matrix.org Foundation C.I.C. +Copyright 2020-2021 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. @@ -21,6 +21,7 @@ import {XOR} from "../../../@types/common"; export interface IProps { description: ReactNode; + detail?: ReactNode; acceptLabel: string; onAccept(); @@ -33,14 +34,19 @@ interface IPropsExtended extends IProps { const GenericToast: React.FC> = ({ description, + detail, acceptLabel, rejectLabel, onAccept, onReject, }) => { + const detailContent = detail ? + {detail} + : null; + return
- { description } + {description} {detailContent}
{onReject && rejectLabel && } diff --git a/src/components/views/toasts/VerificationRequestToast.tsx b/src/components/views/toasts/VerificationRequestToast.tsx index d3da282c1c..56be23aa7e 100644 --- a/src/components/views/toasts/VerificationRequestToast.tsx +++ b/src/components/views/toasts/VerificationRequestToast.tsx @@ -1,5 +1,5 @@ /* -Copyright 2019 The Matrix.org Foundation C.I.C. +Copyright 2019-2021 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. @@ -140,11 +140,12 @@ export default class VerificationRequestToast extends React.PureComponentrequests.": "Your server isn't responding to some requests.", - "From %(deviceName)s (%(deviceId)s) at %(ip)s": "From %(deviceName)s (%(deviceId)s) at %(ip)s", "Decline (%(counter)s)": "Decline (%(counter)s)", "Accept to continue:": "Accept to continue:", "Delete": "Delete", @@ -1674,7 +1673,7 @@ "In encrypted rooms, like this one, URL previews are disabled by default to ensure that your homeserver (where the previews are generated) cannot gather information about links you see in this room.": "In encrypted rooms, like this one, URL previews are disabled by default to ensure that your homeserver (where the previews are generated) cannot gather information about links you see in this room.", "When someone puts a URL in their message, a URL preview can be shown to give more information about that link such as the title, description, and an image from the website.": "When someone puts a URL in their message, a URL preview can be shown to give more information about that link such as the title, description, and an image from the website.", "Back": "Back", - "Waiting for you to accept on your other session…": "Waiting for you to accept on your other session…", + "Accept on your other login…": "Accept on your other login…", "Waiting for %(displayName)s to accept…": "Waiting for %(displayName)s to accept…", "Accepting…": "Accepting…", "Start Verification": "Start Verification", @@ -2348,7 +2347,7 @@ "Upload %(count)s other files|one": "Upload %(count)s other file", "Cancel All": "Cancel All", "Upload Error": "Upload Error", - "Verify other session": "Verify other session", + "Verify other login": "Verify other login", "Verification Request": "Verification Request", "Approve widget permissions": "Approve widget permissions", "This widget would like to:": "This widget would like to:", @@ -2549,7 +2548,7 @@ "Review terms and conditions": "Review terms and conditions", "Old cryptography data detected": "Old cryptography data detected", "Data from an older version of %(brand)s has been detected. This will have caused end-to-end cryptography to malfunction in the older version. End-to-end encrypted messages exchanged recently whilst using the older version may not be decryptable in this version. This may also cause messages exchanged with this version to fail. If you experience problems, log out and back in again. To retain message history, export and re-import your keys.": "Data from an older version of %(brand)s has been detected. This will have caused end-to-end cryptography to malfunction in the older version. End-to-end encrypted messages exchanged recently whilst using the older version may not be decryptable in this version. This may also cause messages exchanged with this version to fail. If you experience problems, log out and back in again. To retain message history, export and re-import your keys.", - "Self-verification request": "Self-verification request", + "Verification requested": "Verification requested", "Logout": "Logout", "%(creator)s created this DM.": "%(creator)s created this DM.", "%(creator)s created and configured the room.": "%(creator)s created and configured the room.", @@ -2739,11 +2738,11 @@ "Decide where your account is hosted": "Decide where your account is hosted", "Use Security Key or Phrase": "Use Security Key or Phrase", "Use Security Key": "Use Security Key", - "Verify with another session": "Verify with another session", - "Verify this login to access your encrypted messages and prove to others that this login is really you.": "Verify this login to access your encrypted messages and prove to others that this login is really you.", + "Use another login": "Use another login", + "Verify your identity to access encrypted messages and prove your identity to others.": "Verify your identity to access encrypted messages and prove your identity to others.", "Your new session is now verified. It has access to your encrypted messages, and other users will see it as trusted.": "Your new session is now verified. It has access to your encrypted messages, and other users will see it as trusted.", "Your new session is now verified. Other users will see it as trusted.": "Your new session is now verified. Other users will see it as trusted.", - "Without completing security on this session, it won’t have access to encrypted messages.": "Without completing security on this session, it won’t have access to encrypted messages.", + "Without verifying, you won’t have access to all your messages and may appear as untrusted to others.": "Without verifying, you won’t have access to all your messages and may appear as untrusted to others.", "Failed to re-authenticate due to a homeserver problem": "Failed to re-authenticate due to a homeserver problem", "Incorrect password": "Incorrect password", "Failed to re-authenticate": "Failed to re-authenticate", diff --git a/src/toasts/BulkUnverifiedSessionsToast.ts b/src/toasts/BulkUnverifiedSessionsToast.ts index bc129ebd54..e063f72fe0 100644 --- a/src/toasts/BulkUnverifiedSessionsToast.ts +++ b/src/toasts/BulkUnverifiedSessionsToast.ts @@ -42,7 +42,7 @@ export const showToast = (deviceIds: Set) => { title: _t("You have unverified logins"), icon: "verification_warning", props: { - description: _t("Verify all your sessions to ensure your account & messages are safe"), + description: _t("Review to ensure your account is safe"), acceptLabel: _t("Review"), onAccept, rejectLabel: _t("Later"), diff --git a/src/toasts/UnverifiedSessionToast.ts b/src/toasts/UnverifiedSessionToast.ts index e0ea323033..c856d39d1f 100644 --- a/src/toasts/UnverifiedSessionToast.ts +++ b/src/toasts/UnverifiedSessionToast.ts @@ -49,13 +49,11 @@ export const showToast = async (deviceId: string) => { title: _t("New login. Was this you?"), icon: "verification_warning", props: { - description: _t( - "A new login is accessing your account: %(name)s (%(deviceID)s) at %(ip)s", { - name: device.display_name, - deviceID: deviceId, - ip: device.last_seen_ip, - }, - ), + description: device.display_name, + detail: _t("%(deviceId)s from %(ip)s", { + deviceId, + ip: device.last_seen_ip, + }), acceptLabel: _t("Check your devices"), onAccept, rejectLabel: _t("Later"), From 9aa1daa3e190c428dacd88f13bc543dcd1dbe1f3 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Fri, 26 Mar 2021 11:43:41 +0000 Subject: [PATCH 06/11] Move toast detail to a new line --- src/components/views/toasts/GenericToast.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/views/toasts/GenericToast.tsx b/src/components/views/toasts/GenericToast.tsx index 200c88875e..209babbf9d 100644 --- a/src/components/views/toasts/GenericToast.tsx +++ b/src/components/views/toasts/GenericToast.tsx @@ -40,13 +40,14 @@ const GenericToast: React.FC> = ({ onAccept, onReject, }) => { - const detailContent = detail ? + const detailContent = detail ?
{detail} - : null; +
: null; return
- {description} {detailContent} + {description} + {detailContent}
{onReject && rejectLabel && } From 52cda49ba4c6c774f776a26cfb827df6ca287c6e Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Fri, 26 Mar 2021 11:56:58 +0000 Subject: [PATCH 07/11] Fix tests --- test/end-to-end-tests/src/usecases/verify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/end-to-end-tests/src/usecases/verify.js b/test/end-to-end-tests/src/usecases/verify.js index 98e73ad6b7..ea5b9961a4 100644 --- a/test/end-to-end-tests/src/usecases/verify.js +++ b/test/end-to-end-tests/src/usecases/verify.js @@ -93,7 +93,7 @@ module.exports.acceptSasVerification = async function(session, name) { // verify the toast is for verification const toastHeader = await requestToast.$("h2"); const toastHeaderText = await session.innerText(toastHeader); - assert.equal(toastHeaderText, 'Verification Request'); + assert.equal(toastHeaderText, 'Verification requested'); const toastDescription = await requestToast.$(".mx_Toast_description"); const toastDescText = await session.innerText(toastDescription); assert.equal(toastDescText.startsWith(name), true, From 1426a4b16872f948811c0c35666506c3595c8717 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 25 Mar 2021 22:22:43 -0600 Subject: [PATCH 08/11] Fix crash on login when using social login We weren't passing a matrix client through, and the peg wasn't set at this point. Just need to thread it through to the media endpoints. Fixes https://github.com/vector-im/element-web/issues/16765 --- src/components/views/elements/SSOButtons.tsx | 2 +- src/customisations/Media.ts | 27 +++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/components/views/elements/SSOButtons.tsx b/src/components/views/elements/SSOButtons.tsx index 4e41db0ae7..a9eb04d4ec 100644 --- a/src/components/views/elements/SSOButtons.tsx +++ b/src/components/views/elements/SSOButtons.tsx @@ -73,7 +73,7 @@ const SSOButton: React.FC = ({ brandClass = `mx_SSOButton_brand_${brandName}`; icon = {brandName}; } else if (typeof idp?.icon === "string" && idp.icon.startsWith("mxc://")) { - const src = mediaFromMxc(idp.icon).getSquareThumbnailHttp(24); + const src = mediaFromMxc(idp.icon, matrixClient).getSquareThumbnailHttp(24); icon = {idp.name}; } diff --git a/src/customisations/Media.ts b/src/customisations/Media.ts index f262179f3d..b651e40a3b 100644 --- a/src/customisations/Media.ts +++ b/src/customisations/Media.ts @@ -17,6 +17,7 @@ import {MatrixClientPeg} from "../MatrixClientPeg"; import {IMediaEventContent, IPreparedMedia, prepEventContentAsMedia} from "./models/IMediaEventContent"; import {ResizeMethod} from "../Avatar"; +import {MatrixClient} from "matrix-js-sdk/src/client"; // Populate this class with the details of your customisations when copying it. @@ -30,8 +31,14 @@ import {ResizeMethod} from "../Avatar"; * "thumbnail media", derived from event contents or external sources. */ export class Media { + private client: MatrixClient; + // Per above, this constructor signature can be whatever is helpful for you. - constructor(private prepared: IPreparedMedia) { + constructor(private prepared: IPreparedMedia, client?: MatrixClient) { + this.client = client ?? MatrixClientPeg.get(); + if (!this.client) { + throw new Error("No possible MatrixClient for media resolution. Please provide one or log in."); + } } /** @@ -67,7 +74,7 @@ export class Media { * The HTTP URL for the source media. */ public get srcHttp(): string { - return MatrixClientPeg.get().mxcUrlToHttp(this.srcMxc); + return this.client.mxcUrlToHttp(this.srcMxc); } /** @@ -76,7 +83,7 @@ export class Media { */ public get thumbnailHttp(): string | undefined | null { if (!this.hasThumbnail) return null; - return MatrixClientPeg.get().mxcUrlToHttp(this.thumbnailMxc); + return this.client.mxcUrlToHttp(this.thumbnailMxc); } /** @@ -89,7 +96,7 @@ export class Media { */ public getThumbnailHttp(width: number, height: number, mode: ResizeMethod = "scale"): string | null | undefined { if (!this.hasThumbnail) return null; - return MatrixClientPeg.get().mxcUrlToHttp(this.thumbnailMxc, width, height, mode); + return this.client.mxcUrlToHttp(this.thumbnailMxc, width, height, mode); } /** @@ -100,7 +107,7 @@ export class Media { * @returns {string} The HTTP URL which points to the thumbnail. */ public getThumbnailOfSourceHttp(width: number, height: number, mode: ResizeMethod = "scale"): string { - return MatrixClientPeg.get().mxcUrlToHttp(this.srcMxc, width, height, mode); + return this.client.mxcUrlToHttp(this.srcMxc, width, height, mode); } /** @@ -128,17 +135,19 @@ export class Media { /** * Creates a media object from event content. * @param {IMediaEventContent} content The event content. + * @param {MatrixClient} client? Optional client to use. * @returns {Media} The media object. */ -export function mediaFromContent(content: IMediaEventContent): Media { - return new Media(prepEventContentAsMedia(content)); +export function mediaFromContent(content: IMediaEventContent, client?: MatrixClient): Media { + return new Media(prepEventContentAsMedia(content), client); } /** * Creates a media object from an MXC URI. * @param {string} mxc The MXC URI. + * @param {MatrixClient} client? Optional client to use. * @returns {Media} The media object. */ -export function mediaFromMxc(mxc: string): Media { - return mediaFromContent({url: mxc}); +export function mediaFromMxc(mxc: string, client?: MatrixClient): Media { + return mediaFromContent({url: mxc}, client); } From 805e980a8a62ca031a9fcbecca5d9466b40fee10 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Mon, 29 Mar 2021 13:29:12 +0100 Subject: [PATCH 09/11] Upgrade matrix-js-sdk to 9.10.0 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 0f742e2920..0125b00da7 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "katex": "^0.12.0", "linkifyjs": "^2.1.9", "lodash": "^4.17.20", - "matrix-js-sdk": "9.10.0-rc.1", + "matrix-js-sdk": "9.10.0", "matrix-widget-api": "^0.1.0-beta.13", "minimist": "^1.2.5", "pako": "^2.0.3", diff --git a/yarn.lock b/yarn.lock index cc79a1c61d..e94e901fd3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5587,10 +5587,10 @@ mathml-tag-names@^2.1.3: resolved "https://registry.yarnpkg.com/mathml-tag-names/-/mathml-tag-names-2.1.3.tgz#4ddadd67308e780cf16a47685878ee27b736a0a3" integrity sha512-APMBEanjybaPzUrfqU0IMU5I0AswKMH7k8OTLs0vvV4KZpExkTkY87nR/zpbuTPj+gARop7aGUbl11pnDfW6xg== -matrix-js-sdk@9.10.0-rc.1: - version "9.10.0-rc.1" - resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-9.10.0-rc.1.tgz#614f9429edc76348deb86ca436897c27d6849eb1" - integrity sha512-aJLXIKDcO4aGPU3dSfonYL2MXo2pz3USMqvFTmw5mfdVQKcgo8blHq6l/C8WEBk0r3oJfbG5E4O0HES5rdUSqA== +matrix-js-sdk@9.10.0: + version "9.10.0" + resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-9.10.0.tgz#ba32981391168778b301c01362a503a8469d3844" + integrity sha512-xvpgvTmCbS8dRTVvVULKbSwyES0y2F17TPukLIIXZMTqqeEBhfycVIjCV6LuACc0WBoRsZbi1/BIlgeWY7J03A== dependencies: "@babel/runtime" "^7.12.5" another-json "^0.2.0" From 61361395ef4019dc102acdc89c47d88c7c1e09b5 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Mon, 29 Mar 2021 13:35:35 +0100 Subject: [PATCH 10/11] Prepare changelog for v3.17.0 --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15e09a2bb0..c839fc2b73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +Changes in [3.17.0](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v3.17.0) (2021-03-29) +===================================================================================================== +[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v3.17.0-rc.1...v3.17.0) + + * Upgrade to JS SDK 9.10.0 + * [Release] Tweak cross-signing copy + [\#5808](https://github.com/matrix-org/matrix-react-sdk/pull/5808) + * [Release] Fix crash on login when using social login + [\#5809](https://github.com/matrix-org/matrix-react-sdk/pull/5809) + * [Release] Fix edge case with redaction grouper messing up continuations + [\#5799](https://github.com/matrix-org/matrix-react-sdk/pull/5799) + Changes in [3.17.0-rc.1](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v3.17.0-rc.1) (2021-03-25) =============================================================================================================== [Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v3.16.0...v3.17.0-rc.1) From 397f7f2e0b815004190e5f12b45d2018955ab0d7 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Mon, 29 Mar 2021 13:35:36 +0100 Subject: [PATCH 11/11] v3.17.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0125b00da7..a2fdf5b5df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-react-sdk", - "version": "3.17.0-rc.1", + "version": "3.17.0", "description": "SDK for matrix.org using React", "author": "matrix.org", "repository": {