Skip to content

Commit 1d34114

Browse files
committed
lint fix
1 parent 06438a4 commit 1d34114

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

packages/host/app/services/matrix-sdk-loader.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export type ExtendedClient = Pick<
7070
| 'fetchRoomEvent'
7171
| 'forget'
7272
| 'getAccessToken'
73+
| 'getAccountData'
7374
| 'getJoinedRooms'
7475
| 'getProfileInfo'
7576
| 'getRoom'
@@ -92,7 +93,6 @@ export type ExtendedClient = Pick<
9293
| 'sendEvent'
9394
| 'sendReadReceipt'
9495
| 'sendStateEvent'
95-
| 'setAccountData'
9696
| 'setDisplayName'
9797
| 'setPassword'
9898
| 'setPowerLevel'

packages/host/tests/helpers/mock-matrix.ts

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface Config {
1616
expiresInSec?: number;
1717
autostart?: boolean;
1818
now?: () => number;
19+
directRooms?: Record<string, string[]>;
1920
}
2021

2122
export function setupMockMatrix(

packages/host/tests/helpers/mock-matrix/_client.ts

+18-2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ export class MockClient implements ExtendedClient {
121121
setAccountData<T>(type: string, data: T): Promise<{}> {
122122
if (type === APP_BOXEL_REALMS_EVENT_TYPE) {
123123
this.sdkOpts.activeRealms = (data as any).realms;
124+
} else if (type === 'm.direct') {
125+
this.sdkOpts.directRooms = data as any;
124126
} else {
125127
throw new Error(
126128
'Support for updating this event type in account data is not yet implemented in this mock.',
@@ -129,8 +131,22 @@ export class MockClient implements ExtendedClient {
129131
return Promise.resolve({});
130132
}
131133

132-
getAccountData<T>(_type: string): Promise<T> {
133-
throw new Error('Method not implemented.');
134+
getAccountData(eventType: string): MatrixEvent | undefined {
135+
if (eventType === 'm.direct') {
136+
return new MatrixEvent({
137+
type: 'm.direct',
138+
content: this.sdkOpts.directRooms || {},
139+
});
140+
}
141+
if (eventType === APP_BOXEL_REALMS_EVENT_TYPE) {
142+
return new MatrixEvent({
143+
type: APP_BOXEL_REALMS_EVENT_TYPE,
144+
content: {
145+
realms: this.sdkOpts.activeRealms || [],
146+
},
147+
});
148+
}
149+
return undefined;
134150
}
135151

136152
addThreePidOnly(_data: MatrixSDK.IAddThreePidOnlyBody): Promise<{}> {

packages/realm-server/tests/auth-client-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module(basename(__filename), function () {
3838
throw new Error('Method not implemented.');
3939
},
4040
async getAccountData() {
41-
return Promise.resolve({});
41+
return {};
4242
},
4343
async setAccountData() {
4444
return Promise.resolve();

packages/runtime-common/realm-auth-client.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface RealmAuthMatrixClientInterface {
1414
joinRoom(room: string): Promise<any>;
1515
sendEvent(room: string, type: string, content: any): Promise<any>;
1616
hashMessageWithSecret(message: string): Promise<string>;
17-
getAccountData(type: string): Promise<any>;
17+
getAccountData(type: string): any;
1818
setAccountData(type: string, data: any): Promise<any>;
1919
}
2020

@@ -103,7 +103,7 @@ export class RealmAuthClient {
103103
await this.matrixClient.joinRoom(room);
104104
}
105105

106-
let directRooms = await this.matrixClient.getAccountData('m.direct');
106+
let directRooms = this.matrixClient.getAccountData('m.direct');
107107
let userId = this.matrixClient.getUserId() as string;
108108
if (!directRooms?.[userId]?.includes(room)) {
109109
await this.matrixClient.setAccountData('m.direct', {

0 commit comments

Comments
 (0)