- sessions.forEach(async session => {
- try {
- const response = await this.services.groupsService.contents(userUuid, getParams(dataExplorer, searchValue, sq), session);
- api.dispatch(updateResources(response.items));
- api.dispatch(setItems(response));
- } catch {
- api.dispatch(couldNotFetchSearchResults(session));
- }
- });
+
+ if (searchValue.trim() === '') {
+ return;
+ }
+
+ const params = getParams(dataExplorer, searchValue);
+
+ const initial = {
+ itemsAvailable: 0,
+ items: [] as GroupContentsResource[],
+ kind: '',
+ offset: 0,
+ limit: 10
+ };
+
+ if (criteriaChanged) {
+ api.dispatch(setItems(initial));
+ }
+
+ sessions.map(session =>
+ this.services.groupsService.contents('', params, session)
+ .then((response) => {
+ api.dispatch(updateResources(response.items));
+ api.dispatch(appendItems(response));
+ }).catch(() => {
+ api.dispatch(couldNotFetchSearchResults(session.clusterId));
+ })
+ );