Skip to content

Commit

Permalink
return empty array if userIds.length === 0 (#3424)
Browse files Browse the repository at this point in the history
  • Loading branch information
wentokay authored Mar 21, 2023
1 parent 4477cdb commit e9d443e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backend/native/backend-ws/src/db/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const chain = Chain(AUTH_HASURA_URL, {
export const getUsers = async (
userIds: string[]
): Promise<{ id: string; username: string }[]> => {
// hotfix: empty array returns all records
if (userIds.filter(Boolean).length === 0) return [];

const response = await chain("query")(
{
auth_users: [
Expand Down
3 changes: 3 additions & 0 deletions backend/native/backpack-api/src/db/friendships.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ export const getFriendshipStatus = async (
remoteRequested: boolean;
}[]
> => {
// hotfix: empty array returns all records
if (userIds.filter(Boolean).length === 0) return [];

const response = await chain("query")(
{
auth_friendships: [
Expand Down
6 changes: 6 additions & 0 deletions backend/native/backpack-api/src/db/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export const getUsersMetadata = async (
id: unknown;
}[]
> => {
// hotfix: empty array returns all records
if (userIds.filter(Boolean).length === 0) return [];

const response = await chain("query")(
{
auth_users: [
Expand Down Expand Up @@ -50,6 +53,9 @@ export const getUsers = async (
publicKeys: unknown[];
}[]
> => {
// hotfix: empty array returns all records
if (userIds.filter(Boolean).length === 0) return [];

const response = await chain("query")(
{
auth_users: [
Expand Down

1 comment on commit e9d443e

@vercel
Copy link

@vercel vercel bot commented on e9d443e Mar 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.