21364: added commentary Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox@curii...
[arvados.git] / services / workbench2 / src / store / search-results-panel / search-results-middleware-service.ts
index dab83e0114d431b8e15cc6a6e68078f4d7696e0d..8e5ad1bec1d0065ced4d710db99089ba53d8c919 100644 (file)
@@ -63,6 +63,12 @@ export class SearchResultsMiddlewareService extends DataExplorerMiddlewareServic
         api.dispatch(progressIndicatorActions.START_WORKING(this.id))
         api.dispatch(dataExplorerActions.SET_IS_NOT_FOUND({ id: this.id, isNotFound: false }));
 
+        //In all other data tables, itemsAvailable will equal the number of returned items for a single session.
+        //In SearchResultsPanel, multiple sessions can be queried so items available needs to be
+        //reset in order to prevent adding the current value to the previous value every time 
+        //the 'load more' button is clicked.
+        api.dispatch(resetItemsAvailable());
+
         sessions.forEach(session => {
             const params = getParams(dataExplorer, searchValue, session.apiRevision);
             this.services.groupsService.contents('', params, session)
@@ -135,6 +141,9 @@ export const setItems = (listResults: ListResults<GroupContentsResource>) =>
         items: listResults.items.map(resource => resource.uuid),
     });
 
+export const resetItemsAvailable = () =>
+    searchResultsPanelActions.RESET_ITEMS_AVAILABLE();
+
 export const appendItems = (listResults: ListResults<GroupContentsResource>) =>
     searchResultsPanelActions.APPEND_ITEMS({
         ...listResultsToDataExplorerItemsMeta(listResults),