Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 278bae5

Browse files
authored
Merge branch 'develop' into andybalaam/performance-of-geteventtiles-with-hidden-events
2 parents 1e82679 + fc7d0ee commit 278bae5

File tree

9 files changed

+114
-58
lines changed

9 files changed

+114
-58
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
"@types/escape-html": "^1.0.1",
153153
"@types/file-saver": "^2.0.3",
154154
"@types/flux": "^3.1.9",
155-
"@types/fs-extra": "^9.0.13",
155+
"@types/fs-extra": "^11.0.0",
156156
"@types/geojson": "^7946.0.8",
157157
"@types/jest": "^29.2.1",
158158
"@types/katex": "^0.14.0",

src/components/structures/RoomView.tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ export interface IRoomState {
223223
narrow: boolean;
224224
// List of undecryptable events currently visible on-screen
225225
visibleDecryptionFailures?: MatrixEvent[];
226+
msc3946ProcessDynamicPredecessor: boolean;
226227
}
227228

228229
interface LocalRoomViewProps {
@@ -416,6 +417,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
416417
liveTimeline: undefined,
417418
narrow: false,
418419
visibleDecryptionFailures: [],
420+
msc3946ProcessDynamicPredecessor: SettingsStore.getValue("feature_dynamic_room_predecessors"),
419421
};
420422

421423
this.dispatcherRef = dis.register(this.onAction);
@@ -467,6 +469,9 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
467469
),
468470
SettingsStore.watchSetting("urlPreviewsEnabled", null, this.onUrlPreviewsEnabledChange),
469471
SettingsStore.watchSetting("urlPreviewsEnabled_e2ee", null, this.onUrlPreviewsEnabledChange),
472+
SettingsStore.watchSetting("feature_dynamic_room_predecessors", null, (...[, , , value]) =>
473+
this.setState({ msc3946ProcessDynamicPredecessor: value as boolean }),
474+
),
470475
];
471476
}
472477

@@ -1798,10 +1803,8 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
17981803
};
17991804

18001805
private getOldRoom(): Room | null {
1801-
const createEvent = this.state.room.currentState.getStateEvents(EventType.RoomCreate, "");
1802-
if (!createEvent || !createEvent.getContent()["predecessor"]) return null;
1803-
1804-
return this.context.client.getRoom(createEvent.getContent()["predecessor"]["room_id"]);
1806+
const { roomId } = this.state.room?.findPredecessor(this.state.msc3946ProcessDynamicPredecessor) || {};
1807+
return this.context.client?.getRoom(roomId) || null;
18051808
}
18061809

18071810
public getHiddenHighlightCount(): number {

src/components/views/settings/SecureBackupPanel.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ export default class SecureBackupPanel extends React.PureComponent<{}, IState> {
242242
let restoreButtonCaption = _t("Restore from Backup");
243243

244244
if (MatrixClientPeg.get().getKeyBackupEnabled()) {
245-
statusDescription = <p>{_t("This session is backing up your keys. ")}</p>;
245+
statusDescription = <p>{_t("This session is backing up your keys.")}</p>;
246246
} else {
247247
statusDescription = (
248248
<>

src/contexts/RoomContext.ts

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const RoomContext = createContext<IRoomState>({
6565
liveTimeline: undefined,
6666
narrow: false,
6767
activeCall: null,
68+
msc3946ProcessDynamicPredecessor: false,
6869
});
6970
RoomContext.displayName = "RoomContext";
7071
export default RoomContext;

src/i18n/strings/en_EN.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,7 @@
14531453
"Are you sure? You will lose your encrypted messages if your keys are not backed up properly.": "Are you sure? You will lose your encrypted messages if your keys are not backed up properly.",
14541454
"Unable to load key backup status": "Unable to load key backup status",
14551455
"Restore from Backup": "Restore from Backup",
1456-
"This session is backing up your keys. ": "This session is backing up your keys. ",
1456+
"This session is backing up your keys.": "This session is backing up your keys.",
14571457
"This session is <b>not backing up your keys</b>, but you do have an existing backup you can restore from and add to going forward.": "This session is <b>not backing up your keys</b>, but you do have an existing backup you can restore from and add to going forward.",
14581458
"Connect this session to key backup before signing out to avoid losing any keys that may only be on this session.": "Connect this session to key backup before signing out to avoid losing any keys that may only be on this session.",
14591459
"Connect this session to Key Backup": "Connect this session to Key Backup",

test/components/structures/RoomView-test.tsx

+42-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const RoomView = wrapInMatrixClientContext(_RoomView);
5555
describe("RoomView", () => {
5656
let cli: MockedObject<MatrixClient>;
5757
let room: Room;
58+
let rooms: Map<string, Room>;
5859
let roomCount = 0;
5960
let stores: SdkContextClass;
6061

@@ -64,8 +65,11 @@ describe("RoomView", () => {
6465
cli = mocked(MatrixClientPeg.get());
6566

6667
room = new Room(`!${roomCount++}:example.org`, cli, "@alice:example.org");
68+
jest.spyOn(room, "findPredecessor");
6769
room.getPendingEvents = () => [];
68-
cli.getRoom.mockImplementation(() => room);
70+
rooms = new Map();
71+
rooms.set(room.roomId, room);
72+
cli.getRoom.mockImplementation((roomId: string | undefined) => rooms.get(roomId || "") || null);
6973
// Re-emit certain events on the mocked client
7074
room.on(RoomEvent.Timeline, (...args) => cli.emit(RoomEvent.Timeline, ...args));
7175
room.on(RoomEvent.TimelineReset, (...args) => cli.emit(RoomEvent.TimelineReset, ...args));
@@ -158,6 +162,42 @@ describe("RoomView", () => {
158162
const getRoomViewInstance = async (): Promise<_RoomView> =>
159163
(await mountRoomView()).find(_RoomView).instance() as _RoomView;
160164

165+
it("when there is no room predecessor, getHiddenHighlightCount should return 0", async () => {
166+
const instance = await getRoomViewInstance();
167+
expect(instance.getHiddenHighlightCount()).toBe(0);
168+
});
169+
170+
describe("when there is an old room", () => {
171+
let instance: _RoomView;
172+
let oldRoom: Room;
173+
174+
beforeEach(async () => {
175+
instance = await getRoomViewInstance();
176+
oldRoom = new Room("!old:example.com", cli, cli.getSafeUserId());
177+
rooms.set(oldRoom.roomId, oldRoom);
178+
jest.spyOn(room, "findPredecessor").mockReturnValue({ roomId: oldRoom.roomId, eventId: null });
179+
});
180+
181+
it("and it has 0 unreads, getHiddenHighlightCount should return 0", async () => {
182+
jest.spyOn(oldRoom, "getUnreadNotificationCount").mockReturnValue(0);
183+
expect(instance.getHiddenHighlightCount()).toBe(0);
184+
// assert that msc3946ProcessDynamicPredecessor is false by default
185+
expect(room.findPredecessor).toHaveBeenCalledWith(false);
186+
});
187+
188+
it("and it has 23 unreads, getHiddenHighlightCount should return 23", async () => {
189+
jest.spyOn(oldRoom, "getUnreadNotificationCount").mockReturnValue(23);
190+
expect(instance.getHiddenHighlightCount()).toBe(23);
191+
});
192+
193+
it("and feature_dynamic_room_predecessors is enabled it should pass the setting to findPredecessor", async () => {
194+
SettingsStore.setValue("feature_dynamic_room_predecessors", null, SettingLevel.DEVICE, true);
195+
expect(instance.getHiddenHighlightCount()).toBe(0);
196+
expect(room.findPredecessor).toHaveBeenCalledWith(true);
197+
SettingsStore.setValue("feature_dynamic_room_predecessors", null, SettingLevel.DEVICE, null);
198+
});
199+
});
200+
161201
it("updates url preview visibility on encryption state change", async () => {
162202
// we should be starting unencrypted
163203
expect(cli.isCryptoEnabled()).toEqual(false);
@@ -248,6 +288,7 @@ describe("RoomView", () => {
248288

249289
beforeEach(async () => {
250290
localRoom = room = await createDmLocalRoom(cli, [new DirectoryMember({ user_id: "@user:example.com" })]);
291+
rooms.set(localRoom.roomId, localRoom);
251292
cli.store.storeRoom(room);
252293
});
253294

test/components/views/rooms/SendMessageComposer-test.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ describe("<SendMessageComposer/>", () => {
7878
resizing: false,
7979
narrow: false,
8080
activeCall: null,
81+
msc3946ProcessDynamicPredecessor: false,
8182
};
8283
describe("createMessageContent", () => {
8384
const permalinkCreator = jest.fn() as any;

test/test-utils/room.ts

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export function getRoomContext(room: Room, override: Partial<IRoomState>): IRoom
8686
resizing: false,
8787
narrow: false,
8888
activeCall: null,
89+
msc3946ProcessDynamicPredecessor: false,
8990

9091
...override,
9192
};

yarn.lock

+59-50
Original file line numberDiff line numberDiff line change
@@ -2127,11 +2127,12 @@
21272127
"@types/fbemitter" "*"
21282128
"@types/react" "*"
21292129

2130-
"@types/fs-extra@^9.0.13":
2131-
version "9.0.13"
2132-
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.13.tgz#7594fbae04fe7f1918ce8b3d213f74ff44ac1f45"
2133-
integrity sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==
2130+
"@types/fs-extra@^11.0.0":
2131+
version "11.0.1"
2132+
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-11.0.1.tgz#f542ec47810532a8a252127e6e105f487e0a6ea5"
2133+
integrity sha512-MxObHvNl4A69ofaTRU8DFqvgzzv8s9yRtaPPm5gud9HDNvpB3GPQFvNuTWAI59B9huVGV5jXYJwbCsmBsOGYWA==
21342134
dependencies:
2135+
"@types/jsonfile" "*"
21352136
"@types/node" "*"
21362137

21372138
"@types/geojson@*", "@types/geojson@^7946.0.10", "@types/geojson@^7946.0.8":
@@ -2200,6 +2201,13 @@
22002201
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
22012202
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==
22022203

2204+
"@types/jsonfile@*":
2205+
version "6.1.1"
2206+
resolved "https://registry.yarnpkg.com/@types/jsonfile/-/jsonfile-6.1.1.tgz#ac84e9aefa74a2425a0fb3012bdea44f58970f1b"
2207+
integrity sha512-GSgiRCVeapDN+3pqA35IkQwasaCh/0YFH5dEF6S88iDvEn901DjOeH3/QPY+XYP1DFzDZPvIvfeEgk+7br5png==
2208+
dependencies:
2209+
"@types/node" "*"
2210+
22032211
"@types/katex@^0.14.0":
22042212
version "0.14.0"
22052213
resolved "https://registry.yarnpkg.com/@types/katex/-/katex-0.14.0.tgz#b84c0afc3218069a5ad64fe2a95321881021b5fe"
@@ -2417,86 +2425,87 @@
24172425
integrity sha512-3NoqvZC2W5gAC5DZbTpCeJ251vGQmgcWIHQJGq2J240HY6ErQ9aWKkwfoKJlHLx+A83WPNTZ9+3cd2ILxbvr1w==
24182426

24192427
"@typescript-eslint/eslint-plugin@^5.35.1":
2420-
version "5.48.1"
2421-
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.48.1.tgz#deee67e399f2cb6b4608c935777110e509d8018c"
2422-
integrity sha512-9nY5K1Rp2ppmpb9s9S2aBiF3xo5uExCehMDmYmmFqqyxgenbHJ3qbarcLt4ITgaD6r/2ypdlcFRdcuVPnks+fQ==
2428+
version "5.51.0"
2429+
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.51.0.tgz#da3f2819633061ced84bb82c53bba45a6fe9963a"
2430+
integrity sha512-wcAwhEWm1RgNd7dxD/o+nnLW8oH+6RK1OGnmbmkj/GGoDPV1WWMVP0FXYQBivKHdwM1pwii3bt//RC62EriIUQ==
24232431
dependencies:
2424-
"@typescript-eslint/scope-manager" "5.48.1"
2425-
"@typescript-eslint/type-utils" "5.48.1"
2426-
"@typescript-eslint/utils" "5.48.1"
2432+
"@typescript-eslint/scope-manager" "5.51.0"
2433+
"@typescript-eslint/type-utils" "5.51.0"
2434+
"@typescript-eslint/utils" "5.51.0"
24272435
debug "^4.3.4"
2436+
grapheme-splitter "^1.0.4"
24282437
ignore "^5.2.0"
24292438
natural-compare-lite "^1.4.0"
24302439
regexpp "^3.2.0"
24312440
semver "^7.3.7"
24322441
tsutils "^3.21.0"
24332442

24342443
"@typescript-eslint/parser@^5.6.0":
2435-
version "5.48.1"
2436-
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.48.1.tgz#d0125792dab7e232035434ab8ef0658154db2f10"
2437-
integrity sha512-4yg+FJR/V1M9Xoq56SF9Iygqm+r5LMXvheo6DQ7/yUWynQ4YfCRnsKuRgqH4EQ5Ya76rVwlEpw4Xu+TgWQUcdA==
2444+
version "5.51.0"
2445+
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.51.0.tgz#2d74626652096d966ef107f44b9479f02f51f271"
2446+
integrity sha512-fEV0R9gGmfpDeRzJXn+fGQKcl0inIeYobmmUWijZh9zA7bxJ8clPhV9up2ZQzATxAiFAECqPQyMDB4o4B81AaA==
24382447
dependencies:
2439-
"@typescript-eslint/scope-manager" "5.48.1"
2440-
"@typescript-eslint/types" "5.48.1"
2441-
"@typescript-eslint/typescript-estree" "5.48.1"
2448+
"@typescript-eslint/scope-manager" "5.51.0"
2449+
"@typescript-eslint/types" "5.51.0"
2450+
"@typescript-eslint/typescript-estree" "5.51.0"
24422451
debug "^4.3.4"
24432452

2444-
"@typescript-eslint/scope-manager@5.48.1":
2445-
version "5.48.1"
2446-
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.48.1.tgz#39c71e4de639f5fe08b988005beaaf6d79f9d64d"
2447-
integrity sha512-S035ueRrbxRMKvSTv9vJKIWgr86BD8s3RqoRZmsSh/s8HhIs90g6UlK8ZabUSjUZQkhVxt7nmZ63VJ9dcZhtDQ==
2453+
"@typescript-eslint/scope-manager@5.51.0":
2454+
version "5.51.0"
2455+
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.51.0.tgz#ad3e3c2ecf762d9a4196c0fbfe19b142ac498990"
2456+
integrity sha512-gNpxRdlx5qw3yaHA0SFuTjW4rxeYhpHxt491PEcKF8Z6zpq0kMhe0Tolxt0qjlojS+/wArSDlj/LtE69xUJphQ==
24482457
dependencies:
2449-
"@typescript-eslint/types" "5.48.1"
2450-
"@typescript-eslint/visitor-keys" "5.48.1"
2458+
"@typescript-eslint/types" "5.51.0"
2459+
"@typescript-eslint/visitor-keys" "5.51.0"
24512460

2452-
"@typescript-eslint/type-utils@5.48.1":
2453-
version "5.48.1"
2454-
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.48.1.tgz#5d94ac0c269a81a91ad77c03407cea2caf481412"
2455-
integrity sha512-Hyr8HU8Alcuva1ppmqSYtM/Gp0q4JOp1F+/JH5D1IZm/bUBrV0edoewQZiEc1r6I8L4JL21broddxK8HAcZiqQ==
2461+
"@typescript-eslint/type-utils@5.51.0":
2462+
version "5.51.0"
2463+
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.51.0.tgz#7af48005531700b62a20963501d47dfb27095988"
2464+
integrity sha512-QHC5KKyfV8sNSyHqfNa0UbTbJ6caB8uhcx2hYcWVvJAZYJRBo5HyyZfzMdRx8nvS+GyMg56fugMzzWnojREuQQ==
24562465
dependencies:
2457-
"@typescript-eslint/typescript-estree" "5.48.1"
2458-
"@typescript-eslint/utils" "5.48.1"
2466+
"@typescript-eslint/typescript-estree" "5.51.0"
2467+
"@typescript-eslint/utils" "5.51.0"
24592468
debug "^4.3.4"
24602469
tsutils "^3.21.0"
24612470

2462-
"@typescript-eslint/types@5.48.1":
2463-
version "5.48.1"
2464-
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.48.1.tgz#efd1913a9aaf67caf8a6e6779fd53e14e8587e14"
2465-
integrity sha512-xHyDLU6MSuEEdIlzrrAerCGS3T7AA/L8Hggd0RCYBi0w3JMvGYxlLlXHeg50JI9Tfg5MrtsfuNxbS/3zF1/ATg==
2471+
"@typescript-eslint/types@5.51.0":
2472+
version "5.51.0"
2473+
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.51.0.tgz#e7c1622f46c7eea7e12bbf1edfb496d4dec37c90"
2474+
integrity sha512-SqOn0ANn/v6hFn0kjvLwiDi4AzR++CBZz0NV5AnusT2/3y32jdc0G4woXPWHCumWtUXZKPAS27/9vziSsC9jnw==
24662475

2467-
"@typescript-eslint/typescript-estree@5.48.1":
2468-
version "5.48.1"
2469-
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.48.1.tgz#9efa8ee2aa471c6ab62e649f6e64d8d121bc2056"
2470-
integrity sha512-Hut+Osk5FYr+sgFh8J/FHjqX6HFcDzTlWLrFqGoK5kVUN3VBHF/QzZmAsIXCQ8T/W9nQNBTqalxi1P3LSqWnRA==
2476+
"@typescript-eslint/typescript-estree@5.51.0":
2477+
version "5.51.0"
2478+
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.51.0.tgz#0ec8170d7247a892c2b21845b06c11eb0718f8de"
2479+
integrity sha512-TSkNupHvNRkoH9FMA3w7TazVFcBPveAAmb7Sz+kArY6sLT86PA5Vx80cKlYmd8m3Ha2SwofM1KwraF24lM9FvA==
24712480
dependencies:
2472-
"@typescript-eslint/types" "5.48.1"
2473-
"@typescript-eslint/visitor-keys" "5.48.1"
2481+
"@typescript-eslint/types" "5.51.0"
2482+
"@typescript-eslint/visitor-keys" "5.51.0"
24742483
debug "^4.3.4"
24752484
globby "^11.1.0"
24762485
is-glob "^4.0.3"
24772486
semver "^7.3.7"
24782487
tsutils "^3.21.0"
24792488

2480-
"@typescript-eslint/utils@5.48.1":
2481-
version "5.48.1"
2482-
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.48.1.tgz#20f2f4e88e9e2a0961cbebcb47a1f0f7da7ba7f9"
2483-
integrity sha512-SmQuSrCGUOdmGMwivW14Z0Lj8dxG1mOFZ7soeJ0TQZEJcs3n5Ndgkg0A4bcMFzBELqLJ6GTHnEU+iIoaD6hFGA==
2489+
"@typescript-eslint/utils@5.51.0":
2490+
version "5.51.0"
2491+
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.51.0.tgz#074f4fabd5b12afe9c8aa6fdee881c050f8b4d47"
2492+
integrity sha512-76qs+5KWcaatmwtwsDJvBk4H76RJQBFe+Gext0EfJdC3Vd2kpY2Pf//OHHzHp84Ciw0/rYoGTDnIAr3uWhhJYw==
24842493
dependencies:
24852494
"@types/json-schema" "^7.0.9"
24862495
"@types/semver" "^7.3.12"
2487-
"@typescript-eslint/scope-manager" "5.48.1"
2488-
"@typescript-eslint/types" "5.48.1"
2489-
"@typescript-eslint/typescript-estree" "5.48.1"
2496+
"@typescript-eslint/scope-manager" "5.51.0"
2497+
"@typescript-eslint/types" "5.51.0"
2498+
"@typescript-eslint/typescript-estree" "5.51.0"
24902499
eslint-scope "^5.1.1"
24912500
eslint-utils "^3.0.0"
24922501
semver "^7.3.7"
24932502

2494-
"@typescript-eslint/visitor-keys@5.48.1":
2495-
version "5.48.1"
2496-
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.48.1.tgz#79fd4fb9996023ef86849bf6f904f33eb6c8fccb"
2497-
integrity sha512-Ns0XBwmfuX7ZknznfXozgnydyR8F6ev/KEGePP4i74uL3ArsKbEhJ7raeKr1JSa997DBDwol/4a0Y+At82c9dA==
2503+
"@typescript-eslint/visitor-keys@5.51.0":
2504+
version "5.51.0"
2505+
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.51.0.tgz#c0147dd9a36c0de758aaebd5b48cae1ec59eba87"
2506+
integrity sha512-Oh2+eTdjHjOFjKA27sxESlA87YPSOJafGCR0md5oeMdh1ZcCfAGCIOL216uTBAkAIptvLIfKQhl7lHxMJet4GQ==
24982507
dependencies:
2499-
"@typescript-eslint/types" "5.48.1"
2508+
"@typescript-eslint/types" "5.51.0"
25002509
eslint-visitor-keys "^3.3.0"
25012510

25022511
"@wojtekmaj/enzyme-adapter-react-17@^0.8.0":

0 commit comments

Comments
 (0)