From 01aca7e3739af57f3f2268b3920242bb07f15d09 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 11 Jan 2023 17:02:54 +0000 Subject: [PATCH 1/3] Fix reply action in message context menu notif & file panels --- src/stores/RoomViewStore.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/stores/RoomViewStore.tsx b/src/stores/RoomViewStore.tsx index 02d8b51a6cd..c851138af6c 100644 --- a/src/stores/RoomViewStore.tsx +++ b/src/stores/RoomViewStore.tsx @@ -302,10 +302,11 @@ export class RoomViewStore extends EventEmitter { this.reset(); break; case 'reply_to_event': - // If currently viewed room does not match the room in which we wish to reply then change rooms - // this can happen when performing a search across all rooms. Persist the data from this event for - // both room and search timeline rendering types, search will get auto-closed by RoomView at this time. - if ([TimelineRenderingType.Room, TimelineRenderingType.Search].includes(payload.context)) { + // Thread timeline view handles its own reply-to-state + if (TimelineRenderingType.Thread !== payload.context) { + // If currently viewed room does not match the room in which we wish to reply then change rooms this + // can happen when performing a search across all rooms. Persist the data from this event for both + // room and search timeline rendering types, search will get auto-closed by RoomView at this time. if (payload.event && payload.event.getRoomId() !== this.state.roomId) { this.dis.dispatch({ action: Action.ViewRoom, From 3c1709a9bc1ec595ef5a8e549673acd136047ad5 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 12 Jan 2023 13:40:10 +0000 Subject: [PATCH 2/3] Add tests --- test/stores/RoomViewStore-test.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/stores/RoomViewStore-test.ts b/test/stores/RoomViewStore-test.ts index 30a8cff02c7..c117e37dc41 100644 --- a/test/stores/RoomViewStore-test.ts +++ b/test/stores/RoomViewStore-test.ts @@ -15,6 +15,7 @@ limitations under the License. */ import { Room } from "matrix-js-sdk/src/matrix"; +import { sleep } from "matrix-js-sdk/src/utils"; import { RoomViewStore } from "../../src/stores/RoomViewStore"; import { Action } from "../../src/dispatcher/actions"; @@ -245,6 +246,29 @@ describe("RoomViewStore", function () { expect(roomViewStore.getRoomId()).toEqual(roomId2); }); + it("should ignore reply_to_event for Thread panels", async () => { + expect(roomViewStore.getQuotingEvent()).toBeFalsy(); + const replyToEvent = { + getRoomId: () => roomId2, + }; + dis.dispatch({ action: "reply_to_event", event: replyToEvent, context: TimelineRenderingType.Thread }); + await sleep(100); + expect(roomViewStore.getQuotingEvent()).toBeFalsy(); + }); + + it.each([ + TimelineRenderingType.Room, + TimelineRenderingType.File, + TimelineRenderingType.Notification, + ])("Should respect reply_to_event for %s rendering context", async (context) => { + const replyToEvent = { + getRoomId: () => roomId, + }; + dis.dispatch({ action: "reply_to_event", event: replyToEvent, context }); + await untilDispatch(Action.ViewRoom, dis); + expect(roomViewStore.getQuotingEvent()).toEqual(replyToEvent); + }); + it("removes the roomId on ViewHomePage", async () => { dis.dispatch({ action: Action.ViewRoom, room_id: roomId }); await untilDispatch(Action.ActiveRoomChanged, dis); From 715fa0cc79ed930093b316da0e6800b13dff2249 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 12 Jan 2023 13:47:53 +0000 Subject: [PATCH 3/3] Run prettier --- test/stores/RoomViewStore-test.ts | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/test/stores/RoomViewStore-test.ts b/test/stores/RoomViewStore-test.ts index c117e37dc41..7c2b1ec81b3 100644 --- a/test/stores/RoomViewStore-test.ts +++ b/test/stores/RoomViewStore-test.ts @@ -256,18 +256,17 @@ describe("RoomViewStore", function () { expect(roomViewStore.getQuotingEvent()).toBeFalsy(); }); - it.each([ - TimelineRenderingType.Room, - TimelineRenderingType.File, - TimelineRenderingType.Notification, - ])("Should respect reply_to_event for %s rendering context", async (context) => { - const replyToEvent = { - getRoomId: () => roomId, - }; - dis.dispatch({ action: "reply_to_event", event: replyToEvent, context }); - await untilDispatch(Action.ViewRoom, dis); - expect(roomViewStore.getQuotingEvent()).toEqual(replyToEvent); - }); + it.each([TimelineRenderingType.Room, TimelineRenderingType.File, TimelineRenderingType.Notification])( + "Should respect reply_to_event for %s rendering context", + async (context) => { + const replyToEvent = { + getRoomId: () => roomId, + }; + dis.dispatch({ action: "reply_to_event", event: replyToEvent, context }); + await untilDispatch(Action.ViewRoom, dis); + expect(roomViewStore.getQuotingEvent()).toEqual(replyToEvent); + }, + ); it("removes the roomId on ViewHomePage", async () => { dis.dispatch({ action: Action.ViewRoom, room_id: roomId });