Skip to content

Commit

Permalink
Refactor MatrixClient::forget to not abuse membershipChange API
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Telatynski <[email protected]>
  • Loading branch information
t3chguy committed Oct 31, 2024
1 parent 546047a commit a0e6d9e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5796,16 +5796,17 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
* @returns Promise which resolves: `{}` an empty object.
* @returns Rejects: with an error response.
*/
public forget(roomId: string, deleteRoom = true): Promise<{}> {
const promise = this.membershipChange(roomId, undefined, "forget");
if (!deleteRoom) {
return promise;
}
return promise.then((response) => {
public async forget(roomId: string, deleteRoom = true): Promise<{}> {
// API returns an empty object
const path = utils.encodeUri("/rooms/$room_id/forget", {
$room_id: roomId,
});
const response = await this.http.authedRequest<{}>(Method.Post, path);
if (deleteRoom) {
this.store.removeRoom(roomId);
this.emit(ClientEvent.DeleteRoom, roomId);
return response;
});
}
return response;
}

/**
Expand Down Expand Up @@ -5846,7 +5847,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
private membershipChange(
roomId: string,
userId: string | undefined,
membership: Membership | "forget",
membership: Membership,
reason?: string,
): Promise<{}> {
// API returns an empty object
Expand Down

0 comments on commit a0e6d9e

Please sign in to comment.