Skip to content

Commit

Permalink
Refactor MatrixClient::forget to not abuse membershipChange API (#4490)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
  • Loading branch information
t3chguy authored Nov 4, 2024
1 parent 1061b93 commit a197afe
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 a197afe

Please sign in to comment.