Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typescript return types for membership update events #1739

Merged
merged 4 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3800,10 +3800,10 @@ export class MatrixClient extends EventEmitter {
* @param {string} userId
* @param {module:client.callback} callback Optional.
* @param {string} reason Optional.
* @return {Promise} Resolves: TODO
* @return {Promise} Resolves: {} an empty object.
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
public invite(roomId: string, userId: string, callback?: Callback, reason?: string): Promise<void> {
public invite(roomId: string, userId: string, callback?: Callback, reason?: string): Promise<{}> {
return this.membershipChange(roomId, userId, "invite", reason, callback);
}

Expand All @@ -3812,10 +3812,10 @@ export class MatrixClient extends EventEmitter {
* @param {string} roomId The room to invite the user to.
* @param {string} email The email address to invite.
* @param {module:client.callback} callback Optional.
* @return {Promise} Resolves: TODO
* @return {Promise} Resolves: {} an empty object.
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
public inviteByEmail(roomId: string, email: string, callback?: Callback): Promise<void> {
public inviteByEmail(roomId: string, email: string, callback?: Callback): Promise<{}> {
return this.inviteByThreePid(roomId, "email", email, callback);
}

Expand All @@ -3825,10 +3825,10 @@ export class MatrixClient extends EventEmitter {
* @param {string} medium The medium to invite the user e.g. "email".
* @param {string} address The address for the specified medium.
* @param {module:client.callback} callback Optional.
* @return {Promise} Resolves: TODO
* @return {Promise} Resolves: {} an empty object.
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
public async inviteByThreePid(roomId: string, medium: string, address: string, callback?: Callback): Promise<void> {
public async inviteByThreePid(roomId: string, medium: string, address: string, callback?: Callback): Promise<{}> {
const path = utils.encodeUri(
"/rooms/$roomId/invite",
{ $roomId: roomId },
Expand Down Expand Up @@ -3864,10 +3864,10 @@ export class MatrixClient extends EventEmitter {
/**
* @param {string} roomId
* @param {module:client.callback} callback Optional.
* @return {Promise} Resolves: TODO
* @return {Promise} Resolves: {} an empty object.
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
public leave(roomId: string, callback?: Callback): Promise<void> {
public leave(roomId: string, callback?: Callback): Promise<{}> {
return this.membershipChange(roomId, undefined, "leave", undefined, callback);
}

Expand Down Expand Up @@ -3935,10 +3935,10 @@ export class MatrixClient extends EventEmitter {
* @param {boolean} deleteRoom True to delete the room from the store on success.
* Default: true.
* @param {module:client.callback} callback Optional.
* @return {Promise} Resolves: TODO
* @return {Promise} Resolves: {} an empty object.
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
public forget(roomId: string, deleteRoom?: boolean, callback?: Callback): Promise<void> {
public forget(roomId: string, deleteRoom?: boolean, callback?: Callback): Promise<{}> {
if (deleteRoom === undefined) {
deleteRoom = true;
}
Expand Down Expand Up @@ -3983,10 +3983,10 @@ export class MatrixClient extends EventEmitter {
* @param {string} userId
* @param {string} reason Optional.
* @param {module:client.callback} callback Optional.
* @return {Promise} Resolves: TODO
* @return {Promise} Resolves: {} an empty object.
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
public kick(roomId: string, userId: string, reason?: string, callback?: Callback): Promise<void> {
public kick(roomId: string, userId: string, reason?: string, callback?: Callback): Promise<{}> {
return this.setMembershipState(roomId, userId, "leave", reason, callback);
}

Expand Down Expand Up @@ -4030,7 +4030,7 @@ export class MatrixClient extends EventEmitter {
membership: string,
reason?: string,
callback?: Callback,
): Promise<void> {
): Promise<{}> {
if (utils.isFunction(reason)) {
callback = reason as any as Callback; // legacy
reason = undefined;
Expand Down
6 changes: 3 additions & 3 deletions src/models/MSC3089TreeSpace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class MSC3089TreeSpace {
* which is an appropriate visibility for these purposes).
* @returns {Promise<void>} Resolves when complete.
*/
public invite(userId: string, andSubspaces = true, shareHistoryKeys = true): Promise<void> {
public async invite(userId: string, andSubspaces = true, shareHistoryKeys = true): Promise<void> {
const promises: Promise<void>[] = [this.retryInvite(userId)];
if (andSubspaces) {
promises.push(...this.getDirectories().map(d => d.invite(userId, andSubspaces, shareHistoryKeys)));
Expand All @@ -146,8 +146,8 @@ export class MSC3089TreeSpace {
}

private retryInvite(userId: string): Promise<void> {
return simpleRetryOperation(() => {
return this.client.invite(this.roomId, userId).catch(e => {
return simpleRetryOperation(async () => {
await this.client.invite(this.roomId, userId).catch(e => {
// We don't want to retry permission errors forever...
if (e?.errcode === "M_FORBIDDEN") {
throw new promiseRetry.AbortError(e);
Expand Down