Przeglądaj źródła

Do not request when an empty string is entered

Shun Miyazawa 4 lat temu
rodzic
commit
bd2341480b
1 zmienionych plików z 1 dodań i 1 usunięć
  1. 1 1
      packages/app/src/stores/user.tsx

+ 1 - 1
packages/app/src/stores/user.tsx

@@ -38,7 +38,7 @@ type usernameResult = {
 
 
 export const useSWRxUsernames = (q: string, offset?: number, limit?: number, options?: usernameRequestOptions): SWRResponse<usernameResult, Error> => {
 export const useSWRxUsernames = (q: string, offset?: number, limit?: number, options?: usernameRequestOptions): SWRResponse<usernameResult, Error> => {
   return useSWRImmutable(
   return useSWRImmutable(
-    q != null ? ['/users/usernames', q, offset, limit, options] : null,
+    (q != null && q.trim() !== '') ? ['/users/usernames', q, offset, limit, options] : null,
     (endpoint, q, offset, limit, options) => apiv3Get(endpoint, {
     (endpoint, q, offset, limit, options) => apiv3Get(endpoint, {
       q, offset, limit, options,
       q, offset, limit, options,
     }).then(result => result.data),
     }).then(result => result.data),