Allow finding group DMs by members in spotlight (#8922)

This commit is contained in:
Janne Mareike Koschinski 2022-06-30 11:44:56 +02:00 committed by GitHub
parent 7e47749ce2
commit d4a4eeaf63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 65 additions and 5 deletions

View file

@ -53,6 +53,12 @@ declare global {
* @param data The data to store.
*/
setAccountData(type: string, data: object): Chainable<{}>;
/**
* Gets the list of DMs with a given user
* @param userId The ID of the user
* @return the list of DMs with that user
*/
getDmRooms(userId: string): Chainable<string[]>;
/**
* Boostraps cross-signing.
*/
@ -65,6 +71,12 @@ Cypress.Commands.add("getClient", (): Chainable<MatrixClient | undefined> => {
return cy.window({ log: false }).then(win => win.mxMatrixClientPeg.matrixClient);
});
Cypress.Commands.add("getDmRooms", (userId: string): Chainable<string[]> => {
return cy.getClient()
.then(cli => cli.getAccountData("m.direct")?.getContent<Record<string, string[]>>())
.then(dmRoomMap => dmRoomMap[userId] ?? []);
});
Cypress.Commands.add("createRoom", (options: ICreateRoomOpts): Chainable<string> => {
return cy.window({ log: false }).then(async win => {
const cli = win.mxMatrixClientPeg.matrixClient;