mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-10-01 15:48:23 -05:00
Fix React duplicate key error with initial users in UserSearch
Not really sure how this works exactly. It doesn't seem the user is visually duplicated despite clearly being there twice in data, something react-aria-components does under the hood perhaps?
This commit is contained in:
@@ -238,12 +238,16 @@ function useUserSearch(
|
||||
[filterText],
|
||||
);
|
||||
|
||||
const initialUserResult = initialUserFetcher.data?.results.find(
|
||||
(r): r is UserResult => r.type === "user",
|
||||
);
|
||||
|
||||
const items = () => {
|
||||
// data fetched for the query user has currently typed
|
||||
if (queryFetcher.data && queryFetcher.data.query === filterText) {
|
||||
const userResults = queryFetcher.data.results.filter(
|
||||
(r): r is UserResult => r.type === "user",
|
||||
);
|
||||
const userResults = queryFetcher.data.results
|
||||
.filter((r): r is UserResult => r.type === "user")
|
||||
.filter((user) => user.id !== initialUserResult?.id);
|
||||
if (userResults.length === 0) {
|
||||
return [{ id: "NO_RESULTS" as const }];
|
||||
}
|
||||
@@ -253,10 +257,6 @@ function useUserSearch(
|
||||
return [{ id: "PLACEHOLDER" as const }];
|
||||
};
|
||||
|
||||
const initialUserResult = initialUserFetcher.data?.results.find(
|
||||
(r): r is UserResult => r.type === "user",
|
||||
);
|
||||
|
||||
return {
|
||||
filterText,
|
||||
setFilterText,
|
||||
|
||||
Reference in New Issue
Block a user