Преглед изворни кода

Merge pull request #5188 from weseek/fix/86680-fetching-child-user-group-error

fix: 86680 Fetching child user group error
Shun Miyazawa пре 4 година
родитељ
комит
4e84182d69
1 измењених фајлова са 3 додато и 2 уклоњено
  1. 3 2
      packages/app/src/stores/user-group.tsx

+ 3 - 2
packages/app/src/stores/user-group.tsx

@@ -21,10 +21,11 @@ export const useSWRxUserGroupList = (initialData?: IUserGroupHasId[]): SWRRespon
 };
 
 export const useSWRxChildUserGroupList = (
-    parentIds: string[] | undefined, includeGrandChildren?: boolean, initialData?: IUserGroupHasId[],
+    parentIds?: string[], includeGrandChildren?: boolean, initialData?: IUserGroupHasId[],
 ): SWRResponse<IUserGroupHasId[], Error> => {
+  const shouldFetch = parentIds != null && parentIds.length > 0;
   return useSWRImmutable<IUserGroupHasId[], Error>(
-    parentIds != null ? ['/user-groups/children', parentIds, includeGrandChildren] : null,
+    shouldFetch ? ['/user-groups/children', parentIds, includeGrandChildren] : null,
     (endpoint, parentIds, includeGrandChildren) => apiv3Get<ChildUserGroupListResult>(
       endpoint, { parentIds, includeGrandChildren },
     ).then(result => result.data.childUserGroups),