Skip to content

Commit 14b424e

Browse files
committed
Merge branch 'develop' of github.com:matrix-org/matrix-js-sdk into t3chguy/fix/18089
2 parents d91d1ce + 696b3ef commit 14b424e

28 files changed

+749
-241
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @matrix-org/element-web
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Preview Changelog
2+
on:
3+
pull_request_target:
4+
types: [ opened, edited, labeled ]
5+
jobs:
6+
changelog:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Preview Changelog
10+
uses: matrix-org/allchange@main
11+
with:
12+
ghToken: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
Changes in [12.2.0](https://github.com/vector-im/element-desktop/releases/tag/v12.2.0) (2021-07-02)
2+
===================================================================================================
3+
4+
## ✨ Features
5+
* Improve calculateRoomName performances by using Intl.Collator
6+
[\#1801](https://github.com/matrix-org/matrix-js-sdk/pull/1801)
7+
* Switch callEventHandler from listening on `event` to `Room.timeline`
8+
[\#1789](https://github.com/matrix-org/matrix-js-sdk/pull/1789)
9+
* Expose MatrixEvent's internal clearEvent as a function
10+
[\#1784](https://github.com/matrix-org/matrix-js-sdk/pull/1784)
11+
12+
## 🐛 Bug Fixes
13+
* Clean up Event.clearEvent handling to fix a bug where malformed events with falsey content wouldn't be considered decrypted
14+
[\#1807](https://github.com/matrix-org/matrix-js-sdk/pull/1807)
15+
* Standardise spelling and casing of homeserver, identity server, and integration manager
16+
[\#1782](https://github.com/matrix-org/matrix-js-sdk/pull/1782)
17+
118
Changes in [12.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v12.1.0) (2021-07-19)
219
==================================================================================================
320
[Full Changelog](https://github.com/matrix-org/matrix-js-sdk/compare/v12.1.0-rc.1...v12.1.0)

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "matrix-js-sdk",
3-
"version": "12.1.0",
3+
"version": "12.2.0",
44
"description": "Matrix Client-Server SDK for Javascript",
55
"scripts": {
66
"prepublishOnly": "yarn build",
@@ -11,7 +11,7 @@
1111
"build:dev": "yarn clean && git rev-parse HEAD > git-revision.txt && yarn build:compile && yarn build:types",
1212
"build:types": "tsc --emitDeclarationOnly",
1313
"build:compile": "babel -d lib --verbose --extensions \".ts,.js\" src",
14-
"build:compile-browser": "mkdirp dist && browserify -d src/browser-index.js -p [ tsify -p ./tsconfig.json ] -t [ babelify --sourceMaps=inline --presets [ @babel/preset-env @babel/preset-typescript ] ] | exorcist dist/browser-matrix.js.map > dist/browser-matrix.js",
14+
"build:compile-browser": "mkdirp dist && browserify -d src/browser-index.js -p [ tsify -p ./tsconfig-build.json ] -t [ babelify --sourceMaps=inline --presets [ @babel/preset-env @babel/preset-typescript ] ] | exorcist dist/browser-matrix.js.map > dist/browser-matrix.js",
1515
"build:minify-browser": "terser dist/browser-matrix.js --compress --mangle --source-map --output dist/browser-matrix.min.js",
1616
"gendoc": "jsdoc -c jsdoc.json -P package.json",
1717
"lint": "yarn lint:types && yarn lint:js",
@@ -81,14 +81,15 @@
8181
"@types/request": "^2.48.5",
8282
"@typescript-eslint/eslint-plugin": "^4.17.0",
8383
"@typescript-eslint/parser": "^4.17.0",
84+
"allchange": "github:matrix-org/allchange",
8485
"babel-jest": "^26.6.3",
8586
"babelify": "^10.0.0",
8687
"better-docs": "^2.4.0-beta.9",
8788
"browserify": "^17.0.0",
8889
"docdash": "^1.2.0",
8990
"eslint": "7.18.0",
9091
"eslint-config-google": "^0.14.0",
91-
"eslint-plugin-matrix-org": "github:matrix-org/eslint-plugin-matrix-org#main",
92+
"eslint-plugin-matrix-org": "github:matrix-org/eslint-plugin-matrix-org#2306b3d4da4eba908b256014b979f1d3d43d2945",
9293
"exorcist": "^1.0.1",
9394
"fake-indexeddb": "^3.1.2",
9495
"jest": "^26.6.3",

release.sh

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,6 @@ yarn cache clean
102102
# Ensure all dependencies are updated
103103
yarn install --ignore-scripts --pure-lockfile
104104

105-
if [ -z "$skip_changelog" ]; then
106-
# update_changelog doesn't have a --version flag
107-
update_changelog -h > /dev/null || (echo "github-changelog-generator is required: please install it"; exit)
108-
fi
109-
110105
# Login and publish continues to use `npm`, as it seems to have more clearly
111106
# defined options and semantics than `yarn` for writing to the registry.
112107
if [ -z "$skip_npm" ]; then
@@ -133,14 +128,6 @@ if [ $prerelease -eq 1 ]; then
133128
echo Making a PRE-RELEASE
134129
fi
135130

136-
if [ -z "$skip_changelog" ]; then
137-
if ! command -v update_changelog >/dev/null 2>&1; then
138-
echo "release.sh requires github-changelog-generator. Try:" >&2
139-
echo " pip install git+https://github.com/matrix-org/github-changelog-generator.git" >&2
140-
exit 1
141-
fi
142-
fi
143-
144131
# we might already be on the release branch, in which case, yay
145132
# If we're on any branch starting with 'release', we don't create
146133
# a separate release branch (this allows us to use the same
@@ -156,7 +143,7 @@ fi
156143

157144
if [ -z "$skip_changelog" ]; then
158145
echo "Generating changelog"
159-
update_changelog -f "$changelog_file" "$release"
146+
yarn run allchange "$release"
160147
read -p "Edit $changelog_file manually, or press enter to continue " REPLY
161148

162149
if [ -n "$(git ls-files --modified $changelog_file)" ]; then

spec/unit/matrix-client.spec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ describe("MatrixClient", function() {
237237
it("should get (unstable) file trees with valid state", async () => {
238238
const roomId = "!room:example.org";
239239
const mockRoom = {
240+
getMyMembership: () => "join",
240241
currentState: {
241242
getStateEvents: (eventType, stateKey) => {
242243
if (eventType === EventType.RoomCreate) {
@@ -270,9 +271,33 @@ describe("MatrixClient", function() {
270271
expect(tree.room).toBe(mockRoom);
271272
});
272273

274+
it("should not get (unstable) file trees if not joined", async () => {
275+
const roomId = "!room:example.org";
276+
const mockRoom = {
277+
getMyMembership: () => "leave", // "not join"
278+
};
279+
client.getRoom = (getRoomId) => {
280+
expect(getRoomId).toEqual(roomId);
281+
return mockRoom;
282+
};
283+
const tree = client.unstableGetFileTreeSpace(roomId);
284+
expect(tree).toBeFalsy();
285+
});
286+
287+
it("should not get (unstable) file trees for unknown rooms", async () => {
288+
const roomId = "!room:example.org";
289+
client.getRoom = (getRoomId) => {
290+
expect(getRoomId).toEqual(roomId);
291+
return null; // imply unknown
292+
};
293+
const tree = client.unstableGetFileTreeSpace(roomId);
294+
expect(tree).toBeFalsy();
295+
});
296+
273297
it("should not get (unstable) file trees with invalid create contents", async () => {
274298
const roomId = "!room:example.org";
275299
const mockRoom = {
300+
getMyMembership: () => "join",
276301
currentState: {
277302
getStateEvents: (eventType, stateKey) => {
278303
if (eventType === EventType.RoomCreate) {
@@ -307,6 +332,7 @@ describe("MatrixClient", function() {
307332
it("should not get (unstable) file trees with invalid purpose/subtype contents", async () => {
308333
const roomId = "!room:example.org";
309334
const mockRoom = {
335+
getMyMembership: () => "join",
310336
currentState: {
311337
getStateEvents: (eventType, stateKey) => {
312338
if (eventType === EventType.RoomCreate) {

spec/unit/models/MSC3089Branch.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ limitations under the License.
1616

1717
import { MatrixClient } from "../../../src";
1818
import { Room } from "../../../src/models/room";
19-
import { MatrixEvent } from "../../../src/models/event";
2019
import { UNSTABLE_MSC3089_BRANCH } from "../../../src/@types/event";
2120
import { EventTimelineSet } from "../../../src/models/event-timeline-set";
2221
import { EventTimeline } from "../../../src/models/event-timeline";
@@ -25,7 +24,7 @@ import { MSC3089Branch } from "../../../src/models/MSC3089Branch";
2524
describe("MSC3089Branch", () => {
2625
let client: MatrixClient;
2726
// @ts-ignore - TS doesn't know that this is a type
28-
let indexEvent: MatrixEvent;
27+
let indexEvent: any;
2928
let branch: MSC3089Branch;
3029

3130
const branchRoomId = "!room:example.org";
@@ -47,10 +46,10 @@ describe("MSC3089Branch", () => {
4746
}
4847
},
4948
};
50-
indexEvent = {
49+
indexEvent = ({
5150
getRoomId: () => branchRoomId,
5251
getStateKey: () => fileEventId,
53-
};
52+
});
5453
branch = new MSC3089Branch(client, indexEvent);
5554
});
5655

spec/unit/models/MSC3089TreeSpace.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { MatrixError } from "../../../src/http-api";
2929

3030
describe("MSC3089TreeSpace", () => {
3131
let client: MatrixClient;
32-
let room: Room;
32+
let room: any;
3333
let tree: MSC3089TreeSpace;
3434
const roomId = "!tree:localhost";
3535
const targetUser = "@target:example.org";
@@ -170,7 +170,7 @@ describe("MSC3089TreeSpace", () => {
170170
expect(userIds).toMatchObject([target]);
171171
return Promise.resolve();
172172
});
173-
client.invite = () => Promise.resolve(); // we're not testing this here - see other tests
173+
client.invite = () => Promise.resolve({}); // we're not testing this here - see other tests
174174
client.sendSharedHistoryKeys = sendKeysFn;
175175

176176
// Mock the history check as best as possible
@@ -198,7 +198,7 @@ describe("MSC3089TreeSpace", () => {
198198
expect(userIds).toMatchObject([target]);
199199
return Promise.resolve();
200200
});
201-
client.invite = () => Promise.resolve(); // we're not testing this here - see other tests
201+
client.invite = () => Promise.resolve({}); // we're not testing this here - see other tests
202202
client.sendSharedHistoryKeys = sendKeysFn;
203203

204204
const historyVis = "joined"; // NOTE: Changed.
@@ -446,9 +446,9 @@ describe("MSC3089TreeSpace", () => {
446446
// Danger: these are partial implementations for testing purposes only
447447

448448
// @ts-ignore - "MatrixEvent is a value but used as a type", which is true but not important
449-
let childState: { [roomId: string]: MatrixEvent[] } = {};
449+
let childState: { [roomId: string]: any[] } = {};
450450
// @ts-ignore - "MatrixEvent is a value but used as a type", which is true but not important
451-
let parentState: MatrixEvent[] = [];
451+
let parentState: any[] = [];
452452
let parentRoom: Room;
453453
let childTrees: MSC3089TreeSpace[];
454454
let rooms: { [roomId: string]: Room };

spec/unit/relations.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ limitations under the License.
1616

1717
import { EventTimelineSet } from "../../src/models/event-timeline-set";
1818
import { MatrixEvent } from "../../src/models/event";
19+
import { Room } from "../../src/models/room";
1920
import { Relations } from "../../src/models/relations";
2021

2122
describe("Relations", function() {
2223
it("should deduplicate annotations", function() {
23-
const relations = new Relations("m.annotation", "m.reaction");
24+
const room = new Room("room123", null, null);
25+
const relations = new Relations("m.annotation", "m.reaction", room);
2426

2527
// Create an instance of an annotation
2628
const eventData = {
@@ -95,10 +97,8 @@ describe("Relations", function() {
9597
});
9698

9799
// Stub the room
98-
const room = {
99-
getPendingEvent() { return null; },
100-
getUnfilteredTimelineSet() { return null; },
101-
};
100+
101+
const room = new Room("room123", null, null);
102102

103103
// Add the target event first, then the relation event
104104
{

spec/unit/utils.spec.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,4 +493,68 @@ describe("utils", function() {
493493
expect(deepSortedObjectEntries(input)).toMatchObject(output);
494494
});
495495
});
496+
497+
describe("recursivelyAssign", () => {
498+
it("doesn't override with null/undefined", () => {
499+
const result = utils.recursivelyAssign(
500+
{
501+
string: "Hello world",
502+
object: {},
503+
float: 0.1,
504+
}, {
505+
string: null,
506+
object: undefined,
507+
},
508+
true,
509+
);
510+
511+
expect(result).toStrictEqual({
512+
string: "Hello world",
513+
object: {},
514+
float: 0.1,
515+
});
516+
});
517+
518+
it("assigns recursively", () => {
519+
const result = utils.recursivelyAssign(
520+
{
521+
number: 42,
522+
object: {
523+
message: "Hello world",
524+
day: "Monday",
525+
langs: {
526+
compiled: ["c++"],
527+
},
528+
},
529+
thing: "string",
530+
}, {
531+
number: 2,
532+
object: {
533+
message: "How are you",
534+
day: "Friday",
535+
langs: {
536+
compiled: ["c++", "c"],
537+
},
538+
},
539+
thing: {
540+
aSubThing: "something",
541+
},
542+
},
543+
);
544+
545+
expect(result).toStrictEqual({
546+
number: 2,
547+
object: {
548+
message: "How are you",
549+
day: "Friday",
550+
langs: {
551+
compiled: ["c++", "c"],
552+
},
553+
},
554+
thing: {
555+
aSubThing: "something",
556+
},
557+
});
558+
});
559+
});
496560
});

0 commit comments

Comments
 (0)