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

add back deprecated aliases #615

Merged
merged 1 commit into from
Feb 11, 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
37 changes: 37 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,18 @@ export class StreamChat<
return this.setUserPromise;
};

/**
* @deprecated Please use connectUser() function instead. Its naming is more consistent with its functionality.
*
* setUser - Set the current user and open a WebSocket connection
*
* @param {OwnUserResponse<ChannelType, CommandType, UserType> | UserResponse<UserType>} user Data about this user. IE {name: "john"}
* @param {TokenOrProvider} userTokenOrProvider Token or provider
*
* @return {ConnectAPIResponse<ChannelType, CommandType, UserType>} Returns a promise that resolves when the connection is setup
*/
setUser = this.connectUser;

_setToken = (user: UserResponse<UserType>, userTokenOrProvider: TokenOrProvider) =>
this.tokenManager.setTokenOrProvider(userTokenOrProvider, user);

Expand Down Expand Up @@ -675,6 +687,11 @@ export class StreamChat<
return this._setupConnection();
};

/**
* @deprecated Please use connectAnonymousUser. Its naming is more consistent with its functionality.
*/
setAnonymousUser = this.connectAnonymousUser;

/**
* setGuestUser - Setup a temporary guest user
*
Expand Down Expand Up @@ -1780,6 +1797,16 @@ export class StreamChat<
});
}

/**
* @deprecated Please use upsertUsers() function instead.
*
* updateUsers - Batch update the list of users
*
* @param {UserResponse<UserType>[]} users list of users
* @return {Promise<APIResponse & { users: { [key: string]: UserResponse<UserType> } }>}
*/
updateUsers = this.upsertUsers;

/**
* upsertUser - Update or Create the given user object
*
Expand All @@ -1791,6 +1818,16 @@ export class StreamChat<
return this.upsertUsers([userObject]);
}

/**
* @deprecated Please use upsertUser() function instead.
*
* updateUser - Update or Create the given user object
*
* @param {UserResponse<UserType>} userObject user object, the only required field is the user id. IE {id: "myuser"} is valid
* @return {Promise<APIResponse & { users: { [key: string]: UserResponse<UserType> } }>}
*/
updateUser = this.upsertUser;

/**
* partialUpdateUsers - Batch partial update of users
*
Expand Down
3 changes: 3 additions & 0 deletions test/typescript/unit-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ voidReturn = client.off('message.new', eventHandler);
let userReturn: ConnectAPIResponse<ChannelType, CommandType, UserType>;
userReturn = client.connectUser({ id: 'john', phone: 2 }, devToken);
userReturn = client.connectUser({ id: 'john', phone: 2 }, async () => 'token');
userReturn = client.setUser({ id: 'john', phone: 2 }, devToken);
userReturn = client.setUser({ id: 'john', phone: 2 }, async () => 'token');

userReturn = client.connectAnonymousUser();
userReturn = client.setAnonymousUser();
userReturn = client.setGuestUser({ id: 'steven' });

type X = { x: string };
Expand Down