Skip to content

Commit 6e3761e

Browse files
author
root
committed
fix(matrix): satisfy thread read lint
1 parent 974bf31 commit 6e3761e

2 files changed

Lines changed: 22 additions & 21 deletions

File tree

extensions/matrix/src/matrix/actions/messages.test.ts

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -760,33 +760,34 @@ describe("matrix message actions", () => {
760760
const hydrateEvents = vi.fn(
761761
async (_roomId: string, events: Array<Record<string, unknown>>) => events,
762762
);
763+
const getEvent = vi.fn(async (_roomId: string, eventId: string) =>
764+
eventId === "$thread-reply"
765+
? {
766+
event_id: "$thread-reply",
767+
sender: "@bob:example.org",
768+
type: "m.room.message",
769+
origin_server_ts: 20,
770+
content: {
771+
msgtype: "m.text",
772+
body: "thread reply",
773+
"m.relates_to": {
774+
rel_type: "m.thread",
775+
event_id: "$thread-root",
776+
},
777+
},
778+
}
779+
: null,
780+
);
763781
const client = {
764782
doRequest,
765783
hydrateEvents,
766-
getEvent: vi.fn(async (_roomId: string, eventId: string) =>
767-
eventId === "$thread-reply"
768-
? {
769-
event_id: "$thread-reply",
770-
sender: "@bob:example.org",
771-
type: "m.room.message",
772-
origin_server_ts: 20,
773-
content: {
774-
msgtype: "m.text",
775-
body: "thread reply",
776-
"m.relates_to": {
777-
rel_type: "m.thread",
778-
event_id: "$thread-root",
779-
},
780-
},
781-
}
782-
: null,
783-
),
784+
getEvent,
784785
stop: vi.fn(),
785786
} as unknown as MatrixClient;
786787

787788
const result = await readMatrixMessages("room:!room:example.org", { client, limit: 5 });
788789

789-
expect(client.getEvent).toHaveBeenCalledWith("!room:example.org", "$thread-reply");
790+
expect(getEvent).toHaveBeenCalledWith("!room:example.org", "$thread-reply");
790791
expect(result.messages.map((message) => message.eventId)).toEqual(["$main-1"]);
791792
});
792793

extensions/matrix/src/matrix/actions/messages.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ export async function readMatrixMessages(
279279
return await withResolvedRoomAction(roomId, opts, async (client, resolvedRoom) => {
280280
const limit = resolveMatrixActionLimit(opts.limit, 20);
281281

282-
let nextBatch: string | null = null;
283-
let prevBatch: string | null = null;
282+
let nextBatch: string | null;
283+
let prevBatch: string | null;
284284
let hydratedChunk: MatrixRawEvent[];
285285

286286
if (opts.threadId) {

0 commit comments

Comments
 (0)