From 1c1d5ea5a90dc3606e4901b1f71af22998700b0a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 14 Apr 2022 12:07:43 +0100 Subject: [PATCH 01/21] [Release] Fixes around threads beta in degraded mode (#8319) * Fix soft crash around the thread panel in degraded mode * Better specify fallback key * Hide MAB Threads prompt if user would have degraded mode * Confirm user wants to enable Threads beta if in degraded mode * Fix copy --- src/components/structures/ThreadPanel.tsx | 2 +- .../views/messages/MessageActionBar.tsx | 6 +++ src/i18n/strings/en_EN.json | 4 ++ src/settings/Settings.tsx | 5 +- src/settings/SettingsStore.ts | 9 ++-- src/settings/controllers/SettingController.ts | 11 ++++ .../controllers/ThreadBetaController.tsx | 53 +++++++++++++++++++ 7 files changed, 82 insertions(+), 8 deletions(-) create mode 100644 src/settings/controllers/ThreadBetaController.tsx diff --git a/src/components/structures/ThreadPanel.tsx b/src/components/structures/ThreadPanel.tsx index 7d75f918589..bc2c53d2035 100644 --- a/src/components/structures/ThreadPanel.tsx +++ b/src/components/structures/ThreadPanel.tsx @@ -286,7 +286,7 @@ const ThreadPanel: React.FC = ({ /> { timelineSet && ( Learn more.": "Your homeserver does not currently support threads, so this feature may be unreliable. Some threaded messages may not be reliably available. Learn more.", + "Do you want to enable threads anyway?": "Do you want to enable threads anyway?", + "Yes, enable": "Yes, enable", "Collecting app version information": "Collecting app version information", "Collecting logs": "Collecting logs", "Uploading logs": "Uploading logs", diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index 8cd842b74e5..bd34297161b 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -42,6 +42,7 @@ import IncompatibleController from "./controllers/IncompatibleController"; import { ImageSize } from "./enums/ImageSize"; import { MetaSpace } from "../stores/spaces"; import SdkConfig from "../SdkConfig"; +import ThreadBetaController from './controllers/ThreadBetaController'; // These are just a bunch of helper arrays to avoid copy/pasting a bunch of times const LEVELS_ROOM_SETTINGS = [ @@ -222,9 +223,7 @@ export const SETTINGS: {[setting: string]: ISetting} = { "feature_thread": { isFeature: true, labsGroup: LabGroup.Messaging, - // Requires a reload as we change an option flag on the `js-sdk` - // And the entire sync history needs to be parsed again - controller: new ReloadOnChangeController(), + controller: new ThreadBetaController(), displayName: _td("Threaded messaging"), supportedLevels: LEVELS_FEATURE, default: false, diff --git a/src/settings/SettingsStore.ts b/src/settings/SettingsStore.ts index ca9bfe3703e..95ea0e6993e 100644 --- a/src/settings/SettingsStore.ts +++ b/src/settings/SettingsStore.ts @@ -451,12 +451,13 @@ export default class SettingsStore { throw new Error("User cannot set " + settingName + " at " + level + " in " + roomId); } + if (setting.controller && !(await setting.controller.beforeChange(level, roomId, value))) { + return; // controller says no + } + await handler.setValue(settingName, roomId, value); - const controller = setting.controller; - if (controller) { - controller.onChange(level, roomId, value); - } + setting.controller?.onChange(level, roomId, value); } /** diff --git a/src/settings/controllers/SettingController.ts b/src/settings/controllers/SettingController.ts index 292b2d63e59..a274bcff2c3 100644 --- a/src/settings/controllers/SettingController.ts +++ b/src/settings/controllers/SettingController.ts @@ -46,6 +46,17 @@ export default abstract class SettingController { return null; // no override } + /** + * Called before the setting value has been changed, can abort the change. + * @param {string} level The level at which the setting has been modified. + * @param {String} roomId The room ID, may be null. + * @param {*} newValue The new value for the setting, may be null. + * @return {boolean} Whether the settings change should be accepted. + */ + public async beforeChange(level: SettingLevel, roomId: string, newValue: any): Promise { + return true; + } + /** * Called when the setting value has been changed. * @param {string} level The level at which the setting has been modified. diff --git a/src/settings/controllers/ThreadBetaController.tsx b/src/settings/controllers/ThreadBetaController.tsx new file mode 100644 index 00000000000..487d2013b17 --- /dev/null +++ b/src/settings/controllers/ThreadBetaController.tsx @@ -0,0 +1,53 @@ +/* +Copyright 2022 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. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import * as React from "react"; +import { Thread } from "matrix-js-sdk/src/models/thread"; + +import SettingController from "./SettingController"; +import PlatformPeg from "../../PlatformPeg"; +import { SettingLevel } from "../SettingLevel"; +import Modal from "../../Modal"; +import QuestionDialog from "../../components/views/dialogs/QuestionDialog"; +import { _t } from "../../languageHandler"; + +export default class ThreadBetaController extends SettingController { + public async beforeChange(level: SettingLevel, roomId: string, newValue: any): Promise { + if (Thread.hasServerSideSupport || !newValue) return true; // Full support or user is disabling + + const { finished } = Modal.createTrackedDialog<[boolean]>("Thread beta", "degraded mode", QuestionDialog, { + title: _t("Partial Support for Threads"), + description: <> +

{ _t("Your homeserver does not currently support threads, so this feature may be unreliable. " + + "Some threaded messages may not be reliably available. Learn more.", {}, { + a: sub => ( + { sub } + ), + }) }

+

{ _t("Do you want to enable threads anyway?") }

+ , + button: _t("Yes, enable"), + }); + const [enable] = await finished; + return enable; + } + + public onChange(level: SettingLevel, roomId: string, newValue: any) { + // Requires a reload as we change an option flag on the `js-sdk` + // And the entire sync history needs to be parsed again + PlatformPeg.get().reload(); + } +} From b91429fdf995a0cf4ac68757157aa9fb23d69a03 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Thu, 14 Apr 2022 13:56:13 +0100 Subject: [PATCH 02/21] Prepare changelog for v3.42.4 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0126f1f369f..62f25872eca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Changes in [3.42.4](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v3.42.4) (2022-04-14) +===================================================================================================== + +## πŸ› Bug Fixes + * Fixes around threads beta in degraded mode ([\#8319](https://github.com/matrix-org/matrix-react-sdk/pull/8319)). Fixes vector-im/element-web#21762. + Changes in [3.42.3](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v3.42.3) (2022-04-12) ===================================================================================================== From b6155e56c09ce488a3b40524a79a89395323b317 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Thu, 14 Apr 2022 13:56:13 +0100 Subject: [PATCH 03/21] v3.42.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8293d4198db..82f4116272c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-react-sdk", - "version": "3.42.3", + "version": "3.42.4", "description": "SDK for matrix.org using React", "author": "matrix.org", "repository": { From 1da1460baf68d3b50b7b202741a52a71a69d123f Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Tue, 19 Apr 2022 14:54:05 +0100 Subject: [PATCH 04/21] Upgrade matrix-js-sdk to 17.1.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 987c12eb06d..e911e1c4955 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "matrix-analytics-events": "github:matrix-org/matrix-analytics-events.git#daad3faed54f0b1f1e026a7498b4653e4d01cd90", "matrix-encrypt-attachment": "^1.0.3", "matrix-events-sdk": "^0.0.1-beta.7", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop", + "matrix-js-sdk": "17.1.0-rc.1", "matrix-widget-api": "^0.1.0-beta.18", "minimist": "^1.2.5", "opus-recorder": "^8.0.3", diff --git a/yarn.lock b/yarn.lock index d5f058af71f..7e021ae9857 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6651,9 +6651,10 @@ matrix-events-sdk@^0.0.1-beta.7: resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1-beta.7.tgz#5ffe45eba1f67cc8d7c2377736c728b322524934" integrity sha512-9jl4wtWanUFSy2sr2lCjErN/oC8KTAtaeaozJtrgot1JiQcEI4Rda9OLgQ7nLKaqb4Z/QUx/fR3XpDzm5Jy1JA== -"matrix-js-sdk@github:matrix-org/matrix-js-sdk#develop": - version "17.0.0" - resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/b58d09aa9a7a3578c43185becb41ab0b17ce0f98" +matrix-js-sdk@17.1.0-rc.1: + version "17.1.0-rc.1" + resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-17.1.0-rc.1.tgz#e96582e6c35d7c1e77c54b397fa6748fbdabe031" + integrity sha512-iqMS+Sxj6Y+cGS5oV7hnoQp0v58O+4HVjGkxfrJ0mskCJ8xsNQU3M4V8NA8e7atXHzhgqcfbB8RkcHe+WGE1fw== dependencies: "@babel/runtime" "^7.12.5" another-json "^0.2.0" From ff9a563338f2221d57afce2335e5aa0d5a2227aa Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Tue, 19 Apr 2022 14:55:24 +0100 Subject: [PATCH 05/21] Prepare changelog for v3.43.0-rc.1 --- CHANGELOG.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0126f1f369f..5a5a1713048 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,48 @@ +Changes in [3.43.0-rc.1](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v3.43.0-rc.1) (2022-04-19) +=============================================================================================================== + +## ✨ Features + * Improve performance of switching to rooms with lots of servers and ACLs ([\#8347](https://github.com/matrix-org/matrix-react-sdk/pull/8347)). + * Avoid a reflow when setting caret position on an empty composer ([\#8348](https://github.com/matrix-org/matrix-react-sdk/pull/8348)). + * Add message right-click context menu as a labs feature ([\#5672](https://github.com/matrix-org/matrix-react-sdk/pull/5672)). Contributed by @SimonBrandner. + * Live location sharing - basic maximised beacon map ([\#8310](https://github.com/matrix-org/matrix-react-sdk/pull/8310)). + * Live location sharing - render users own beacons in timeline ([\#8296](https://github.com/matrix-org/matrix-react-sdk/pull/8296)). + * Improve Threads beta around degraded mode ([\#8318](https://github.com/matrix-org/matrix-react-sdk/pull/8318)). + * Live location sharing - beacon in timeline happy path ([\#8285](https://github.com/matrix-org/matrix-react-sdk/pull/8285)). + * Add copy button to View Source screen ([\#8278](https://github.com/matrix-org/matrix-react-sdk/pull/8278)). Fixes vector-im/element-web#21482. Contributed by @olivialivia. + * Add heart effect ([\#6188](https://github.com/matrix-org/matrix-react-sdk/pull/6188)). Contributed by @CicadaCinema. + * Update new room icon ([\#8239](https://github.com/matrix-org/matrix-react-sdk/pull/8239)). + +## πŸ› Bug Fixes + * Fix: "Code formatting button does not escape backticks" ([\#8181](https://github.com/matrix-org/matrix-react-sdk/pull/8181)). Contributed by @yaya-usman. + * Fix beta indicator dot causing excessive CPU usage ([\#8340](https://github.com/matrix-org/matrix-react-sdk/pull/8340)). Fixes vector-im/element-web#21793. + * Fix overlapping timestamps on empty messages ([\#8205](https://github.com/matrix-org/matrix-react-sdk/pull/8205)). Fixes vector-im/element-web#21381. Contributed by @goelesha. + * Fix power selector not showing up in user info when state_default undefined ([\#8297](https://github.com/matrix-org/matrix-react-sdk/pull/8297)). Fixes vector-im/element-web#21669. + * Avoid looking up settings during timeline rendering ([\#8313](https://github.com/matrix-org/matrix-react-sdk/pull/8313)). Fixes vector-im/element-web#21740. + * Fix a soft crash with video rooms ([\#8333](https://github.com/matrix-org/matrix-react-sdk/pull/8333)). + * Fixes call tiles overflow ([\#8096](https://github.com/matrix-org/matrix-react-sdk/pull/8096)). Fixes vector-im/element-web#20254. Contributed by @luixxiul. + * Fix a bug with emoji autocomplete sorting where adding the final ":" would cause the emoji with the typed shortcode to no longer be at the top of the autocomplete list. ([\#8086](https://github.com/matrix-org/matrix-react-sdk/pull/8086)). Fixes vector-im/element-web#19302. Contributed by @commonlawfeature. + * Fix image preview sizing for edge cases ([\#8322](https://github.com/matrix-org/matrix-react-sdk/pull/8322)). Fixes vector-im/element-web#20088. + * Refactor SecurityRoomSettingsTab and remove unused state ([\#8306](https://github.com/matrix-org/matrix-react-sdk/pull/8306)). Fixes matrix-org/element-web-rageshakes#12002. + * Don't show the prompt to enable desktop notifications immediately after registration ([\#8274](https://github.com/matrix-org/matrix-react-sdk/pull/8274)). + * Stop tracking threads if threads support is disabled ([\#8308](https://github.com/matrix-org/matrix-react-sdk/pull/8308)). Fixes vector-im/element-web#21766. + * Fix some issues with threads rendering ([\#8305](https://github.com/matrix-org/matrix-react-sdk/pull/8305)). Fixes vector-im/element-web#21670. + * Fix threads rendering issue in Safari ([\#8298](https://github.com/matrix-org/matrix-react-sdk/pull/8298)). Fixes vector-im/element-web#21757. + * Fix space panel width change on hovering over space item ([\#8299](https://github.com/matrix-org/matrix-react-sdk/pull/8299)). Fixes vector-im/element-web#19891. + * Hide the reply in thread button in deployments where beta is forcibly disabled ([\#8294](https://github.com/matrix-org/matrix-react-sdk/pull/8294)). Fixes vector-im/element-web#21753. + * Prevent soft crash around room list header context menu when space changes ([\#8289](https://github.com/matrix-org/matrix-react-sdk/pull/8289)). Fixes matrix-org/element-web-rageshakes#11416, matrix-org/element-web-rageshakes#11692, matrix-org/element-web-rageshakes#11739, matrix-org/element-web-rageshakes#11772, matrix-org/element-web-rageshakes#11891 matrix-org/element-web-rageshakes#11858 and matrix-org/element-web-rageshakes#11456. + * When selecting reply in thread on a thread response open existing thread ([\#8291](https://github.com/matrix-org/matrix-react-sdk/pull/8291)). Fixes vector-im/element-web#21743. + * Handle thread bundled relationships coming from the server via MSC3666 ([\#8292](https://github.com/matrix-org/matrix-react-sdk/pull/8292)). Fixes vector-im/element-web#21450. + * Fix: Avatar preview does not update when same file is selected repeatedly ([\#8288](https://github.com/matrix-org/matrix-react-sdk/pull/8288)). Fixes vector-im/element-web#20098. + * Fix a bug where user gets a warning when changing powerlevel from **Admin** to **custom level (100)** ([\#8248](https://github.com/matrix-org/matrix-react-sdk/pull/8248)). Fixes vector-im/element-web#21682. Contributed by @Jumeb. + * Use a consistent alignment for all text items in a list ([\#8276](https://github.com/matrix-org/matrix-react-sdk/pull/8276)). Fixes vector-im/element-web#21731. Contributed by @luixxiul. + * Fixes button labels being collapsed per a character in CJK languages ([\#8212](https://github.com/matrix-org/matrix-react-sdk/pull/8212)). Fixes vector-im/element-web#21287. Contributed by @luixxiul. + * Fix: Remove jittery timeline scrolling after jumping to an event ([\#8263](https://github.com/matrix-org/matrix-react-sdk/pull/8263)). + * Fix regression of edits showing up in the timeline with hidden events shown ([\#8260](https://github.com/matrix-org/matrix-react-sdk/pull/8260)). Fixes vector-im/element-web#21694. + * Fix reporting events not working ([\#8257](https://github.com/matrix-org/matrix-react-sdk/pull/8257)). Fixes vector-im/element-web#21713. + * Make Jitsi widgets in video rooms immutable ([\#8244](https://github.com/matrix-org/matrix-react-sdk/pull/8244)). Fixes vector-im/element-web#21647. + * Fix: Ensure links to events scroll the correct events into view ([\#8250](https://github.com/matrix-org/matrix-react-sdk/pull/8250)). Fixes vector-im/element-web#19934. + Changes in [3.42.3](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v3.42.3) (2022-04-12) ===================================================================================================== From db89816db909cfb125dcea8aae36f526ebb6b61f Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Tue, 19 Apr 2022 14:55:24 +0100 Subject: [PATCH 06/21] v3.43.0-rc.1 --- package.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index e911e1c4955..b80d9d9975d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-react-sdk", - "version": "3.42.3", + "version": "3.43.0-rc.1", "description": "SDK for matrix.org using React", "author": "matrix.org", "repository": { @@ -22,7 +22,7 @@ "README.md", "package.json" ], - "main": "./src/index.ts", + "main": "./lib/index.ts", "matrix_src_main": "./src/index.ts", "matrix_lib_main": "./lib/index.ts", "matrix_lib_typings": "./lib/index.d.ts", @@ -236,5 +236,6 @@ "text", "json" ] - } + }, + "typings": "./lib/index.d.ts" } From a70f11704f4191e2b84a07f69a3f5982ef6fbeb3 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 26 Apr 2022 09:30:36 +0100 Subject: [PATCH 07/21] Don't form continuations on either side of a thread root (#8408) --- src/components/structures/MessagePanel.tsx | 10 +++++--- .../structures/MessagePanel-test.js | 23 +++++++++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/components/structures/MessagePanel.tsx b/src/components/structures/MessagePanel.tsx index 8600da90475..38d18e92f76 100644 --- a/src/components/structures/MessagePanel.tsx +++ b/src/components/structures/MessagePanel.tsx @@ -92,9 +92,13 @@ export function shouldFormContinuation( mxEvent.sender.name !== prevEvent.sender.name || mxEvent.sender.getMxcAvatarUrl() !== prevEvent.sender.getMxcAvatarUrl()) return false; - // Thread summaries in the main timeline should break up a continuation - if (threadsEnabled && prevEvent.isThreadRoot && - timelineRenderingType !== TimelineRenderingType.Thread) return false; + // Thread summaries in the main timeline should break up a continuation on both sides + if (threadsEnabled && + (mxEvent.isThreadRoot || prevEvent.isThreadRoot) && + timelineRenderingType !== TimelineRenderingType.Thread + ) { + return false; + } // if we don't have tile for previous event then it was shown by showHiddenEvents and has no SenderProfile if (!haveRendererForEvent(prevEvent, showHiddenEvents)) return false; diff --git a/test/components/structures/MessagePanel-test.js b/test/components/structures/MessagePanel-test.js index eca8c39bec9..4b2d5499361 100644 --- a/test/components/structures/MessagePanel-test.js +++ b/test/components/structures/MessagePanel-test.js @@ -674,6 +674,20 @@ describe('MessagePanel', function() { describe("shouldFormContinuation", () => { it("does not form continuations from thread roots", () => { + const message1 = TestUtilsMatrix.mkMessage({ + event: true, + room: "!room:id", + user: "@user:id", + msg: "Here is a message in the main timeline", + }); + + const message2 = TestUtilsMatrix.mkMessage({ + event: true, + room: "!room:id", + user: "@user:id", + msg: "And here's another message in the main timeline", + }); + const threadRoot = TestUtilsMatrix.mkMessage({ event: true, room: "!room:id", @@ -682,14 +696,15 @@ describe("shouldFormContinuation", () => { }); jest.spyOn(threadRoot, "isThreadRoot", "get").mockReturnValue(true); - const message = TestUtilsMatrix.mkMessage({ + const message3 = TestUtilsMatrix.mkMessage({ event: true, room: "!room:id", user: "@user:id", - msg: "And here's another message in the main timeline", + msg: "And here's another message in the main timeline after the thread root", }); - expect(shouldFormContinuation(threadRoot, message, false, true)).toEqual(false); - expect(shouldFormContinuation(message, threadRoot, false, true)).toEqual(true); + expect(shouldFormContinuation(message1, message2, false, true)).toEqual(true); + expect(shouldFormContinuation(message2, threadRoot, false, true)).toEqual(false); + expect(shouldFormContinuation(threadRoot, message3, false, true)).toEqual(false); }); }); From e7c91397f145a569b599413abec477eb434ee3b4 Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski Date: Tue, 26 Apr 2022 12:35:05 +0200 Subject: [PATCH 08/21] Make read receipts handle nullable roomMembers correctly (#8410) * make readReceipt roomMember nullable, as it should be * add fallback click interaction for read receipts of unknown users --- src/components/views/avatars/MemberAvatar.tsx | 2 +- src/components/views/rooms/EventTile.tsx | 2 +- src/components/views/rooms/ReadReceiptGroup.tsx | 11 ++++++++--- src/components/views/rooms/ReadReceiptMarker.tsx | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/views/avatars/MemberAvatar.tsx b/src/components/views/avatars/MemberAvatar.tsx index 09400b7e21d..41ad6118741 100644 --- a/src/components/views/avatars/MemberAvatar.tsx +++ b/src/components/views/avatars/MemberAvatar.tsx @@ -30,7 +30,7 @@ import SettingsStore from "../../../settings/SettingsStore"; import { MatrixClientPeg } from "../../../MatrixClientPeg"; interface IProps extends Omit, "name" | "idName" | "url"> { - member: RoomMember; + member: RoomMember | null; fallbackUserId?: string; width: number; height: number; diff --git a/src/components/views/rooms/EventTile.tsx b/src/components/views/rooms/EventTile.tsx index f068e029a85..d71b682112d 100644 --- a/src/components/views/rooms/EventTile.tsx +++ b/src/components/views/rooms/EventTile.tsx @@ -96,7 +96,7 @@ export type GetRelationsForEvent = (eventId: string, relationType: string, event export interface IReadReceiptProps { userId: string; - roomMember: RoomMember; + roomMember: RoomMember | null; ts: number; } diff --git a/src/components/views/rooms/ReadReceiptGroup.tsx b/src/components/views/rooms/ReadReceiptGroup.tsx index 4363c4c1588..a427c74e072 100644 --- a/src/components/views/rooms/ReadReceiptGroup.tsx +++ b/src/components/views/rooms/ReadReceiptGroup.tsx @@ -15,6 +15,7 @@ limitations under the License. */ import React, { PropsWithChildren, useRef } from "react"; +import { User } from "matrix-js-sdk/src/matrix"; import ReadReceiptMarker, { IReadReceiptInfo } from "./ReadReceiptMarker"; import { IReadReceiptProps } from "./EventTile"; @@ -188,7 +189,7 @@ function ReadReceiptPerson({ userId, roomMember, ts, isTwelveHour, onAfterClick label: ( <>
- { roomMember.rawDisplayName ?? userId } + { roomMember?.rawDisplayName ?? userId }
{ userId } @@ -203,7 +204,11 @@ function ReadReceiptPerson({ userId, roomMember, ts, isTwelveHour, onAfterClick onClick={() => { dis.dispatch({ action: Action.ViewUser, - member: roomMember, + // XXX: We should be using a real member object and not assuming what the receiver wants. + // The ViewUser action leads to the RightPanelStore, and RightPanelStoreIPanelState defines the + // member property of IRightPanelCardState as `RoomMember | User`, so we’re fine for now, but we + // should definitely clean this up later + member: roomMember ?? { userId } as User, push: false, }); onAfterClick?.(); @@ -225,7 +230,7 @@ function ReadReceiptPerson({ userId, roomMember, ts, isTwelveHour, onAfterClick hideTitle />
-

{ roomMember.name }

+

{ roomMember?.name ?? userId }

{ formatDate(new Date(ts), isTwelveHour) }

diff --git a/src/components/views/rooms/ReadReceiptMarker.tsx b/src/components/views/rooms/ReadReceiptMarker.tsx index bf218c0ddb8..453f7dd225e 100644 --- a/src/components/views/rooms/ReadReceiptMarker.tsx +++ b/src/components/views/rooms/ReadReceiptMarker.tsx @@ -31,7 +31,7 @@ export interface IReadReceiptInfo { interface IProps { // the RoomMember to show the RR for - member?: RoomMember; + member?: RoomMember | null; // userId to fallback the avatar to // if the member hasn't been loaded yet fallbackUserId: string; From bff1a3b08891bdf5aeb5888d0a95ff43c9aa2ede Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Tue, 26 Apr 2022 11:36:14 +0100 Subject: [PATCH 09/21] Upgrade matrix-js-sdk to 17.1.0 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index b80d9d9975d..723055e8357 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "matrix-analytics-events": "github:matrix-org/matrix-analytics-events.git#daad3faed54f0b1f1e026a7498b4653e4d01cd90", "matrix-encrypt-attachment": "^1.0.3", "matrix-events-sdk": "^0.0.1-beta.7", - "matrix-js-sdk": "17.1.0-rc.1", + "matrix-js-sdk": "17.1.0", "matrix-widget-api": "^0.1.0-beta.18", "minimist": "^1.2.5", "opus-recorder": "^8.0.3", diff --git a/yarn.lock b/yarn.lock index 7e021ae9857..67697ebb0a1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6651,10 +6651,10 @@ matrix-events-sdk@^0.0.1-beta.7: resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1-beta.7.tgz#5ffe45eba1f67cc8d7c2377736c728b322524934" integrity sha512-9jl4wtWanUFSy2sr2lCjErN/oC8KTAtaeaozJtrgot1JiQcEI4Rda9OLgQ7nLKaqb4Z/QUx/fR3XpDzm5Jy1JA== -matrix-js-sdk@17.1.0-rc.1: - version "17.1.0-rc.1" - resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-17.1.0-rc.1.tgz#e96582e6c35d7c1e77c54b397fa6748fbdabe031" - integrity sha512-iqMS+Sxj6Y+cGS5oV7hnoQp0v58O+4HVjGkxfrJ0mskCJ8xsNQU3M4V8NA8e7atXHzhgqcfbB8RkcHe+WGE1fw== +matrix-js-sdk@17.1.0: + version "17.1.0" + resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-17.1.0.tgz#15335b2f8987c7a7f1b5ef91432f981dbe052fc7" + integrity sha512-1MZYo+B4FnZMII1/Mw0E7WX4erCxnPpeA8fankY5Ql82LQQVSnceOpX2XAsRlDHcxcdExB929KKqVrk/eqDM/A== dependencies: "@babel/runtime" "^7.12.5" another-json "^0.2.0" From 4cf658e7fa7bc98104fa39fd168c6d56a904b79f Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Tue, 26 Apr 2022 11:37:39 +0100 Subject: [PATCH 10/21] Prepare changelog for v3.43.0 --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a5a1713048..4922bfe9619 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,10 @@ -Changes in [3.43.0-rc.1](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v3.43.0-rc.1) (2022-04-19) -=============================================================================================================== +Changes in [3.43.0](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v3.43.0) (2022-04-26) +===================================================================================================== ## ✨ Features * Improve performance of switching to rooms with lots of servers and ACLs ([\#8347](https://github.com/matrix-org/matrix-react-sdk/pull/8347)). * Avoid a reflow when setting caret position on an empty composer ([\#8348](https://github.com/matrix-org/matrix-react-sdk/pull/8348)). - * Add message right-click context menu as a labs feature ([\#5672](https://github.com/matrix-org/matrix-react-sdk/pull/5672)). Contributed by @SimonBrandner. + * Add message right-click context menu as a labs feature ([\#5672](https://github.com/matrix-org/matrix-react-sdk/pull/5672)). * Live location sharing - basic maximised beacon map ([\#8310](https://github.com/matrix-org/matrix-react-sdk/pull/8310)). * Live location sharing - render users own beacons in timeline ([\#8296](https://github.com/matrix-org/matrix-react-sdk/pull/8296)). * Improve Threads beta around degraded mode ([\#8318](https://github.com/matrix-org/matrix-react-sdk/pull/8318)). From 961565967e64147ec52f2663ea0b37f8de22deaf Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Tue, 26 Apr 2022 11:37:40 +0100 Subject: [PATCH 11/21] v3.43.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 723055e8357..d1321890545 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-react-sdk", - "version": "3.43.0-rc.1", + "version": "3.43.0", "description": "SDK for matrix.org using React", "author": "matrix.org", "repository": { From c7c0fdbcc530243ac4675b70826237231f79cb62 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Tue, 26 Apr 2022 12:15:33 +0100 Subject: [PATCH 12/21] 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 d1321890545..210e43ed476 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "matrix-analytics-events": "github:matrix-org/matrix-analytics-events.git#daad3faed54f0b1f1e026a7498b4653e4d01cd90", "matrix-encrypt-attachment": "^1.0.3", "matrix-events-sdk": "^0.0.1-beta.7", - "matrix-js-sdk": "17.1.0", + "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop", "matrix-widget-api": "^0.1.0-beta.18", "minimist": "^1.2.5", "opus-recorder": "^8.0.3", diff --git a/yarn.lock b/yarn.lock index b5ee3782a78..4afef3ab98e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6643,10 +6643,9 @@ matrix-events-sdk@^0.0.1-beta.7: resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1-beta.7.tgz#5ffe45eba1f67cc8d7c2377736c728b322524934" integrity sha512-9jl4wtWanUFSy2sr2lCjErN/oC8KTAtaeaozJtrgot1JiQcEI4Rda9OLgQ7nLKaqb4Z/QUx/fR3XpDzm5Jy1JA== -matrix-js-sdk@17.1.0: +"matrix-js-sdk@github:matrix-org/matrix-js-sdk#develop": version "17.1.0" - resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-17.1.0.tgz#15335b2f8987c7a7f1b5ef91432f981dbe052fc7" - integrity sha512-1MZYo+B4FnZMII1/Mw0E7WX4erCxnPpeA8fankY5Ql82LQQVSnceOpX2XAsRlDHcxcdExB929KKqVrk/eqDM/A== + resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/3649cf46d3435f5b9ff8f60d17f9402c41638dd4" dependencies: "@babel/runtime" "^7.12.5" another-json "^0.2.0" From 9b0ab3321c39a6341481adfa974a096804de1d78 Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski Date: Tue, 26 Apr 2022 13:31:53 +0200 Subject: [PATCH 13/21] Add opt-in analytics to onboarding tasks (#8409) * Add interaction tracking to explore room, send DM and create room events in onboarding view and elsewhere * Update matrix analytics events dependency --- package.json | 2 +- src/components/structures/HomePage.tsx | 6 ++++-- src/components/structures/LeftPanel.tsx | 5 ++++- src/components/views/rooms/RoomList.tsx | 11 +++++++++-- src/components/views/rooms/RoomListHeader.tsx | 2 ++ yarn.lock | 4 ++-- 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 210e43ed476..c62184810c5 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "linkifyjs": "^4.0.0-beta.4", "lodash": "^4.17.20", "maplibre-gl": "^1.15.2", - "matrix-analytics-events": "github:matrix-org/matrix-analytics-events.git#daad3faed54f0b1f1e026a7498b4653e4d01cd90", + "matrix-analytics-events": "github:matrix-org/matrix-analytics-events.git#4aef17b56798639906f26a8739043a3c5c5fde7e", "matrix-encrypt-attachment": "^1.0.3", "matrix-events-sdk": "^0.0.1-beta.7", "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop", diff --git a/src/components/structures/HomePage.tsx b/src/components/structures/HomePage.tsx index fdcb52a6878..ddba1c81d71 100644 --- a/src/components/structures/HomePage.tsx +++ b/src/components/structures/HomePage.tsx @@ -34,13 +34,15 @@ import Analytics from "../../Analytics"; import PosthogTrackers from "../../PosthogTrackers"; import EmbeddedPage from "./EmbeddedPage"; -const onClickSendDm = () => { +const onClickSendDm = (ev: ButtonEvent) => { Analytics.trackEvent('home_page', 'button', 'dm'); + PosthogTrackers.trackInteraction("WebHomeCreateChatButton", ev); dis.dispatch({ action: 'view_create_chat' }); }; -const onClickExplore = () => { +const onClickExplore = (ev: ButtonEvent) => { Analytics.trackEvent('home_page', 'button', 'room_directory'); + PosthogTrackers.trackInteraction("WebHomeExploreRoomsButton", ev); dis.fire(Action.ViewRoomDirectory); }; diff --git a/src/components/structures/LeftPanel.tsx b/src/components/structures/LeftPanel.tsx index 9b4e98e66cb..ed1f990c3f8 100644 --- a/src/components/structures/LeftPanel.tsx +++ b/src/components/structures/LeftPanel.tsx @@ -43,6 +43,8 @@ import SettingsStore from "../../settings/SettingsStore"; import { KeyBindingAction } from "../../accessibility/KeyboardShortcuts"; import { shouldShowComponent } from "../../customisations/helpers/UIComponents"; import { UIComponent } from "../../settings/UIFeature"; +import { ButtonEvent } from "../views/elements/AccessibleButton"; +import PosthogTrackers from "../../PosthogTrackers"; interface IProps { isMinimized: boolean; @@ -116,8 +118,9 @@ export default class LeftPanel extends React.Component { dis.fire(Action.OpenDialPad); }; - private onExplore = () => { + private onExplore = (ev: ButtonEvent) => { dis.fire(Action.ViewRoomDirectory); + PosthogTrackers.trackInteraction("WebLeftPanelExploreRoomsButton", ev); }; private refreshStickyHeaders = () => { diff --git a/src/components/views/rooms/RoomList.tsx b/src/components/views/rooms/RoomList.tsx index 9251cfc2ba6..a7bc539a304 100644 --- a/src/components/views/rooms/RoomList.tsx +++ b/src/components/views/rooms/RoomList.tsx @@ -142,6 +142,7 @@ const DmAuxButton = ({ tabIndex, dispatcher = defaultDispatcher }: IAuxButtonPro e.stopPropagation(); closeMenu(); defaultDispatcher.dispatch({ action: "view_create_chat" }); + PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuCreateChatItem", e); }} /> } { showInviteUsers && dispatcher.dispatch({ action: 'view_create_chat' })} + onClick={(e) => { + dispatcher.dispatch({ action: 'view_create_chat' }); + PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuCreateChatItem", e); + }} className="mx_RoomSublist_auxButton" tooltipClassName="mx_RoomSublist_addRoomTooltip" aria-label={_t("Start chat")} @@ -300,6 +304,7 @@ const UntaggedAuxButton = ({ tabIndex }: IAuxButtonProps) => { e.preventDefault(); e.stopPropagation(); closeMenu(); + PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuExploreRoomsItem", e); defaultDispatcher.fire(Action.ViewRoomDirectory); }} /> @@ -496,9 +501,10 @@ export default class RoomList extends React.PureComponent { } }; - private onStartChat = () => { + private onStartChat = (ev: ButtonEvent) => { const initialText = RoomListStore.instance.getFirstNameFilterCondition()?.search; defaultDispatcher.dispatch({ action: "view_create_chat", initialText }); + PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuCreateChatItem", ev); }; private onExplore = (ev: ButtonEvent) => { @@ -512,6 +518,7 @@ export default class RoomList extends React.PureComponent { } else { const initialText = RoomListStore.instance.getFirstNameFilterCondition()?.search; defaultDispatcher.dispatch({ action: Action.ViewRoomDirectory, initialText }); + PosthogTrackers.trackInteraction("WebRoomListRoomsSublistPlusMenuExploreRoomsItem", ev); } }; diff --git a/src/components/views/rooms/RoomListHeader.tsx b/src/components/views/rooms/RoomListHeader.tsx index 6a892df2386..b8ac024b918 100644 --- a/src/components/views/rooms/RoomListHeader.tsx +++ b/src/components/views/rooms/RoomListHeader.tsx @@ -297,6 +297,7 @@ const RoomListHeader = ({ onVisibilityChange }: IProps) => { e.preventDefault(); e.stopPropagation(); defaultDispatcher.dispatch({ action: "view_create_chat" }); + PosthogTrackers.trackInteraction("WebRoomListHeaderPlusMenuCreateChatItem", e); closePlusMenu(); }} /> @@ -335,6 +336,7 @@ const RoomListHeader = ({ onVisibilityChange }: IProps) => { e.preventDefault(); e.stopPropagation(); defaultDispatcher.dispatch({ action: Action.ViewRoomDirectory }); + PosthogTrackers.trackInteraction("WebRoomListHeaderPlusMenuExploreRoomsItem", e); closePlusMenu(); }} /> diff --git a/yarn.lock b/yarn.lock index 4afef3ab98e..5e5e4838c3f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6629,9 +6629,9 @@ 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-analytics-events@github:matrix-org/matrix-analytics-events.git#daad3faed54f0b1f1e026a7498b4653e4d01cd90": +"matrix-analytics-events@github:matrix-org/matrix-analytics-events.git#4aef17b56798639906f26a8739043a3c5c5fde7e": version "0.0.1" - resolved "https://codeload.github.com/matrix-org/matrix-analytics-events/tar.gz/daad3faed54f0b1f1e026a7498b4653e4d01cd90" + resolved "https://codeload.github.com/matrix-org/matrix-analytics-events/tar.gz/4aef17b56798639906f26a8739043a3c5c5fde7e" matrix-encrypt-attachment@^1.0.3: version "1.0.3" From 942ca743164eb87d4e787bd4072ac8e10bbc4b75 Mon Sep 17 00:00:00 2001 From: Kerry Date: Tue, 26 Apr 2022 14:46:36 +0200 Subject: [PATCH 14/21] update location labs flag descriptions (#8411) Signed-off-by: Kerry Archibald --- src/i18n/strings/en_EN.json | 4 ++-- src/settings/Settings.tsx | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index bf101a8fd36..7223ad37922 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -907,8 +907,8 @@ "Jump to date (adds /jumptodate and jump to date headers)": "Jump to date (adds /jumptodate and jump to date headers)", "Don't send read receipts": "Don't send read receipts", "Right-click message context menu": "Right-click message context menu", - "Location sharing - pin drop (under active development)": "Location sharing - pin drop (under active development)", - "Live location sharing - share current location (active development, and temporarily, locations persist in room history)": "Live location sharing - share current location (active development, and temporarily, locations persist in room history)", + "Location sharing - pin drop": "Location sharing - pin drop", + "Live Location Sharing (temporary implementation: locations persist in room history)": "Live Location Sharing (temporary implementation: locations persist in room history)", "Font size": "Font size", "Use custom size": "Use custom size", "Enable Emoji suggestions while typing": "Enable Emoji suggestions while typing", diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index d9bd0817a4f..e4247908ddf 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -433,7 +433,7 @@ export const SETTINGS: {[setting: string]: ISetting} = { isFeature: true, labsGroup: LabGroup.Messaging, supportedLevels: LEVELS_FEATURE, - displayName: _td("Location sharing - pin drop (under active development)"), + displayName: _td("Location sharing - pin drop"), default: false, }, "feature_location_share_live": { @@ -441,8 +441,7 @@ export const SETTINGS: {[setting: string]: ISetting} = { labsGroup: LabGroup.Messaging, supportedLevels: LEVELS_FEATURE, displayName: _td( - `Live location sharing - share current location ` + - `(active development, and temporarily, locations persist in room history)`, + "Live Location Sharing (temporary implementation: locations persist in room history)", ), default: false, }, From e718242912e2d063a66abc05c2fcab53db18569c Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski Date: Tue, 26 Apr 2022 18:09:41 +0200 Subject: [PATCH 15/21] Read Receipts "Fall from the Sky" (#8414) * fix: don't pass hideTitle to base avatar * fix: correctly position read receipt markers --- src/components/views/avatars/MemberAvatar.tsx | 14 ++- .../views/rooms/ReadReceiptMarker.tsx | 89 ++++++++++++++----- 2 files changed, 76 insertions(+), 27 deletions(-) diff --git a/src/components/views/avatars/MemberAvatar.tsx b/src/components/views/avatars/MemberAvatar.tsx index 41ad6118741..76dc9e69621 100644 --- a/src/components/views/avatars/MemberAvatar.tsx +++ b/src/components/views/avatars/MemberAvatar.tsx @@ -107,8 +107,16 @@ export default class MemberAvatar extends React.PureComponent { } render() { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - let { member, fallbackUserId, onClick, viewUserOnClick, forceHistorical, ...otherProps } = this.props; + let { + member, + fallbackUserId, + onClick, + viewUserOnClick, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + forceHistorical, + hideTitle, + ...otherProps + } = this.props; const userId = member ? member.userId : fallbackUserId; if (viewUserOnClick) { @@ -125,7 +133,7 @@ export default class MemberAvatar extends React.PureComponent { Date: Wed, 27 Apr 2022 09:43:10 +0100 Subject: [PATCH 16/21] Fix editing of non-html replies (#8418) --- src/editor/deserialize.ts | 10 ++++++++-- test/editor/deserialize-test.ts | 20 ++++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/editor/deserialize.ts b/src/editor/deserialize.ts index 57ef52cafd3..c6c9fc35200 100644 --- a/src/editor/deserialize.ts +++ b/src/editor/deserialize.ts @@ -16,12 +16,14 @@ limitations under the License. */ import { MatrixEvent } from "matrix-js-sdk/src/models/event"; +import { MsgType } from "matrix-js-sdk/src/@types/event"; import { checkBlockNode } from "../HtmlUtils"; import { getPrimaryPermalinkEntity } from "../utils/permalinks/Permalinks"; import { Part, PartCreator, Type } from "./parts"; import SdkConfig from "../SdkConfig"; import { textToHtmlRainbow } from "../utils/colour"; +import { stripPlainReply } from "../utils/Reply"; const LIST_TYPES = ["UL", "OL", "LI"]; @@ -288,7 +290,7 @@ export function parsePlainTextMessage( export function parseEvent(event: MatrixEvent, pc: PartCreator, opts: IParseOptions = { shouldEscape: true }) { const content = event.getContent(); let parts: Part[]; - const isEmote = content.msgtype === "m.emote"; + const isEmote = content.msgtype === MsgType.Emote; let isRainbow = false; if (content.format === "org.matrix.custom.html") { @@ -297,7 +299,11 @@ export function parseEvent(event: MatrixEvent, pc: PartCreator, opts: IParseOpti isRainbow = true; } } else { - parts = parsePlainTextMessage(content.body || "", pc, opts); + let body = content.body || ""; + if (event.replyEventId) { + body = stripPlainReply(body); + } + parts = parsePlainTextMessage(body, pc, opts); } if (isEmote && isRainbow) { diff --git a/test/editor/deserialize-test.ts b/test/editor/deserialize-test.ts index 47ab6cb2f27..a6713b3139a 100644 --- a/test/editor/deserialize-test.ts +++ b/test/editor/deserialize-test.ts @@ -20,7 +20,7 @@ import { createPartCreator } from "./mock"; const FOUR_SPACES = " ".repeat(4); -function htmlMessage(formattedBody, msgtype = "m.text") { +function htmlMessage(formattedBody: string, msgtype = "m.text") { return { getContent() { return { @@ -32,7 +32,7 @@ function htmlMessage(formattedBody, msgtype = "m.text") { } as unknown as MatrixEvent; } -function textMessage(body, msgtype = "m.text") { +function textMessage(body: string, msgtype = "m.text") { return { getContent() { return { @@ -43,6 +43,13 @@ function textMessage(body, msgtype = "m.text") { } as unknown as MatrixEvent; } +function textMessageReply(body: string, msgtype = "m.text") { + return { + ...textMessage(body, msgtype), + replyEventId: "!foo:bar", + } as unknown as MatrixEvent; +} + function mergeAdjacentParts(parts) { let prevPart; for (let i = 0; i < parts.length; ++i) { @@ -404,5 +411,14 @@ describe('editor/deserialize', function() { text: "> no formatting here", }); }); + it("it strips plaintext replies", () => { + const body = "> Sender: foo\n\nMessage"; + const parts = normalize(parseEvent(textMessageReply(body), createPartCreator(), { shouldEscape: false })); + expect(parts.length).toBe(1); + expect(parts[0]).toStrictEqual({ + type: "plain", + text: "Message", + }); + }); }); }); From 9ad93c2f5ba37183d623462c8ee6b554335090f6 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 27 Apr 2022 10:24:38 +0100 Subject: [PATCH 17/21] Attempt to use deployments to signal Netlify builds instead (#8421) --- .github/workflows/element-build-and-test.yaml | 13 ++++- .github/workflows/netlify.yaml | 57 +++++++++++++------ 2 files changed, 52 insertions(+), 18 deletions(-) diff --git a/.github/workflows/element-build-and-test.yaml b/.github/workflows/element-build-and-test.yaml index 905dbedb067..2bb95d1c0e1 100644 --- a/.github/workflows/element-build-and-test.yaml +++ b/.github/workflows/element-build-and-test.yaml @@ -23,14 +23,23 @@ jobs: cache: 'yarn' - name: Fetch layered build - run: scripts/ci/layered.sh + id: layered_build + run: | + scripts/ci/layered.sh + JSSDK_SHA=$(git -C matrix-js-sdk rev-parse --short=12 HEAD) + REACT_SHA=$(git rev-parse --short=12 HEAD) + VECTOR_SHA=$(git -C element-web rev-parse --short=12 HEAD) + echo "::set-output name=VERSION::$VECTOR_SHA-react-$REACT_SHA-js-$JSSDK_SHA" - name: Copy config run: cp element.io/develop/config.json config.json working-directory: ./element-web - name: Build - run: CI_PACKAGE=true yarn build + env: + CI_PACKAGE: true + VERSION: "${{ steps.layered_build.outputs.VERSION }}" + run: yarn build working-directory: ./element-web - name: Upload Artifact diff --git a/.github/workflows/netlify.yaml b/.github/workflows/netlify.yaml index 1acb7e8fd14..8db9fba7747 100644 --- a/.github/workflows/netlify.yaml +++ b/.github/workflows/netlify.yaml @@ -7,25 +7,37 @@ on: types: - completed jobs: - build: + deploy: runs-on: ubuntu-latest - if: > - ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' }} + if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' steps: - - name: "πŸ” Read PR number" + - name: "πŸ” Read PR details" id: readctx - # we need to find the PR number that corresponds to the branch, which we do by - # searching the GH API + # we need to find the PR number that corresponds to the branch, which we do by searching the GH API # The workflow_run event includes a list of pull requests, but it doesn't get populated for # forked PRs: https://docs.github.com/en/rest/reference/checks#create-a-check-run run: | head_branch='${{github.event.workflow_run.head_repository.owner.login}}:${{github.event.workflow_run.head_branch}}' echo "head branch: $head_branch" pulls_uri="https://api.github.com/repos/${{ github.repository }}/pulls?head=$(jq -Rr '@uri' <<<$head_branch)" - pr_number=$(curl -s -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' "$pulls_uri" | - jq -r '.[] | .number') + read pr_number, head_ref < <(curl -s -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' "$pulls_uri" | + jq -r '.[] | .number, .head.ref') echo "PR number: $pr_number" + echo "Head ref: $head_ref" echo "::set-output name=prnumber::$pr_number" + echo "::set-output name=headref::$head_ref" + + - name: Create Deployment ID + uses: altinukshini/deployment-action@v1.2.6 + id: deployment + with: + token: "${{ secrets.ELEMENT_BOT_TOKEN }}" + pr: true + pr_id: ${{ steps.readctx.outputs.prnumber }} + transient_environment: true + environment: Netlify + initial_status: in_progress + ref: ${{ steps.readctx.outputs.headref }} # There's a 'download artifact' action but it hasn't been updated for the # workflow_run action (https://github.com/actions/download-artifact/issues/60) @@ -69,12 +81,25 @@ jobs: NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} timeout-minutes: 1 - - name: Edit PR Description - uses: Beakyn/gha-comment-pull-request@2167a7aee24f9e61ce76a23039f322e49a990409 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Update deployment status (success) + if: success() + uses: altinukshini/deployment-status@v1.0.1 + with: + token: "${{ secrets.ELEMENT_BOT_TOKEN }}" + environment_url: ${{ steps.netlify.outputs.deploy-url }} + state: "success" + deployment_id: ${{ steps.deployment.outputs.deployment_id }} + pr: true + pr_id: ${{ steps.readctx.outputs.prnumber }} + description: | + Do you trust the author of this PR? Maybe this build will steal your keys or give you malware. + Exercise caution. Use test accounts. + - name: Update deployment status (failure) + if: failure() + uses: altinukshini/deployment-status@v1.0.1 with: - pull-request-number: ${{ steps.readctx.outputs.prnumber }} - description-message: | - Preview: ${{ steps.netlify.outputs.deploy-url }} - ⚠️ Do you trust the author of this PR? Maybe this build will steal your keys or give you malware. Exercise caution. Use test accounts. + token: "${{ secrets.ELEMENT_BOT_TOKEN }}" + state: "failure" + deployment_id: ${{ steps.deployment.outputs.deployment_id }} + pr: true + pr_id: ${{ steps.readctx.outputs.prnumber }} From 4bcdb5e99b401f12f27dfba4549ab2b5214f8db5 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 27 Apr 2022 10:45:23 +0100 Subject: [PATCH 18/21] Fix broken netlify ci (#8424) --- .github/workflows/netlify.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/netlify.yaml b/.github/workflows/netlify.yaml index 8db9fba7747..0319d51e764 100644 --- a/.github/workflows/netlify.yaml +++ b/.github/workflows/netlify.yaml @@ -20,7 +20,7 @@ jobs: head_branch='${{github.event.workflow_run.head_repository.owner.login}}:${{github.event.workflow_run.head_branch}}' echo "head branch: $head_branch" pulls_uri="https://api.github.com/repos/${{ github.repository }}/pulls?head=$(jq -Rr '@uri' <<<$head_branch)" - read pr_number, head_ref < <(curl -s -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' "$pulls_uri" | + read -d"" pr_number head_ref < <(curl -s -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' "$pulls_uri" | jq -r '.[] | .number, .head.ref') echo "PR number: $pr_number" echo "Head ref: $head_ref" From b6bc2943d30d351b9ea333410fc94894cc821c62 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 27 Apr 2022 11:11:48 +0100 Subject: [PATCH 19/21] Fix it once and for all --- .github/workflows/netlify.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/netlify.yaml b/.github/workflows/netlify.yaml index 0319d51e764..1be1a6a0bd7 100644 --- a/.github/workflows/netlify.yaml +++ b/.github/workflows/netlify.yaml @@ -18,12 +18,12 @@ jobs: # forked PRs: https://docs.github.com/en/rest/reference/checks#create-a-check-run run: | head_branch='${{github.event.workflow_run.head_repository.owner.login}}:${{github.event.workflow_run.head_branch}}' - echo "head branch: $head_branch" + echo "Head branch: $head_branch" + head_ref='${{github.event.workflow_run.head_sha}}' + echo "Head ref: $head_ref" pulls_uri="https://api.github.com/repos/${{ github.repository }}/pulls?head=$(jq -Rr '@uri' <<<$head_branch)" - read -d"" pr_number head_ref < <(curl -s -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' "$pulls_uri" | - jq -r '.[] | .number, .head.ref') + pr_number = $(curl -s -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' "$pulls_uri" | jq -r '.[] | .number) echo "PR number: $pr_number" - echo "Head ref: $head_ref" echo "::set-output name=prnumber::$pr_number" echo "::set-output name=headref::$head_ref" From 8f7e265125b299383ecc80a76747b2fe721b98bc Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 27 Apr 2022 11:20:29 +0100 Subject: [PATCH 20/21] Fix Netlify builds --- .github/workflows/netlify.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/netlify.yaml b/.github/workflows/netlify.yaml index 1be1a6a0bd7..1efa40da3db 100644 --- a/.github/workflows/netlify.yaml +++ b/.github/workflows/netlify.yaml @@ -22,7 +22,7 @@ jobs: head_ref='${{github.event.workflow_run.head_sha}}' echo "Head ref: $head_ref" pulls_uri="https://api.github.com/repos/${{ github.repository }}/pulls?head=$(jq -Rr '@uri' <<<$head_branch)" - pr_number = $(curl -s -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' "$pulls_uri" | jq -r '.[] | .number) + pr_number = $(curl -s -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' "$pulls_uri" | jq -r .[] | .number) echo "PR number: $pr_number" echo "::set-output name=prnumber::$pr_number" echo "::set-output name=headref::$head_ref" From 6d2230064eda126f85bd4cdc7bb3baad6ba80562 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 27 Apr 2022 12:39:14 +0100 Subject: [PATCH 21/21] Fix broken netlify ci (#8427) --- .github/workflows/netlify.yaml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/netlify.yaml b/.github/workflows/netlify.yaml index 1efa40da3db..ac869121cda 100644 --- a/.github/workflows/netlify.yaml +++ b/.github/workflows/netlify.yaml @@ -11,21 +11,19 @@ jobs: runs-on: ubuntu-latest if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' steps: - - name: "πŸ” Read PR details" + - name: "πŸ” Read PR number" id: readctx - # we need to find the PR number that corresponds to the branch, which we do by searching the GH API + # We need to find the PR number that corresponds to the branch, which we do by searching the GH API # The workflow_run event includes a list of pull requests, but it doesn't get populated for # forked PRs: https://docs.github.com/en/rest/reference/checks#create-a-check-run run: | head_branch='${{github.event.workflow_run.head_repository.owner.login}}:${{github.event.workflow_run.head_branch}}' echo "Head branch: $head_branch" - head_ref='${{github.event.workflow_run.head_sha}}' - echo "Head ref: $head_ref" pulls_uri="https://api.github.com/repos/${{ github.repository }}/pulls?head=$(jq -Rr '@uri' <<<$head_branch)" - pr_number = $(curl -s -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' "$pulls_uri" | jq -r .[] | .number) + pr_number=$(curl -s -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' "$pulls_uri" | + jq -r '.[] | .number') echo "PR number: $pr_number" echo "::set-output name=prnumber::$pr_number" - echo "::set-output name=headref::$head_ref" - name: Create Deployment ID uses: altinukshini/deployment-action@v1.2.6 @@ -37,7 +35,7 @@ jobs: transient_environment: true environment: Netlify initial_status: in_progress - ref: ${{ steps.readctx.outputs.headref }} + ref: ${{ github.event.workflow_run.head_sha }} # There's a 'download artifact' action but it hasn't been updated for the # workflow_run action (https://github.com/actions/download-artifact/issues/60)