Skip to content

Commit

Permalink
Hopefully avoid fetching whole users endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
FieryFlames committed Oct 29, 2023
1 parent 0d960c6 commit 4aa195a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export async function cFetch(url: RequestInfo, options?: RequestInit) {
}

export const getUsersDecorations = async (ids: string[] | undefined = undefined) => {
if (ids && ids.length === 0) return {};
const url = new URL(API_URL + "/users");
if (ids && ids.length !== 0) url.searchParams.set("ids", JSON.stringify(ids));

Expand Down
1 change: 1 addition & 0 deletions src/lib/stores/UsersDecorationsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const useUsersDecorationsStore = create<UsersDecorationsState>((set, get)
set({ fetchQueue: new Set() });

const fetchIds = Array.from(fetchQueue);
if (fetchIds.length === 0) return;
const fetchedUsersDecorations = await getUsersDecorations(fetchIds);

const newUsersDecorations = new Map(usersDecorations);
Expand Down

0 comments on commit 4aa195a

Please sign in to comment.