From 7ec5b9aacec8b980271bca3f3b95a01530f99c5c Mon Sep 17 00:00:00 2001 From: Dariusz Szut Date: Mon, 20 Jan 2020 13:50:28 +0100 Subject: [PATCH] EZP-31261: UDW tree is not loaded properly when switching from Bookmarks tab --- .../components/finder/finder.branch.js | 2 +- .../components/grid-view/grid.view.js | 2 +- .../universal-discovery/content.create.tab.module.js | 2 +- .../hooks/useFindLocationsByParentLocationIdFetch.js | 3 +-- .../services/universal.discovery.service.js | 12 +++++++----- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/modules/universal-discovery/components/finder/finder.branch.js b/src/modules/universal-discovery/components/finder/finder.branch.js index bdd040b9..1b4e3c4c 100644 --- a/src/modules/universal-discovery/components/finder/finder.branch.js +++ b/src/modules/universal-discovery/components/finder/finder.branch.js @@ -41,7 +41,7 @@ const FinderBranch = ({ locationData }) => { let resizeStartPositionX = 0; let branchCurrentWidth = 0; const loadMore = ({ target }) => { - const areAllItemsLoaded = loadedLocations.location && locationData.subitems.length >= loadedLocations.location.childCount; + const areAllItemsLoaded = locationData.subitems.length >= loadedLocations.totalCount; const isOffsetReached = target.scrollHeight - target.clientHeight - target.scrollTop < SCROLL_OFFSET; if (areAllItemsLoaded || !isOffsetReached || isLoading) { diff --git a/src/modules/universal-discovery/components/grid-view/grid.view.js b/src/modules/universal-discovery/components/grid-view/grid.view.js index ffb2b8e8..084c1de5 100644 --- a/src/modules/universal-discovery/components/grid-view/grid.view.js +++ b/src/modules/universal-discovery/components/grid-view/grid.view.js @@ -26,7 +26,7 @@ const GridView = () => { true ); const loadMore = ({ target }) => { - const areAllItemsLoaded = loadedLocations.location && locationData.subitems.length >= loadedLocations.location.childCount; + const areAllItemsLoaded = locationData.subitems.length >= loadedLocations.totalCount; const isOffsetReached = target.scrollHeight - target.clientHeight - target.scrollTop < SCROLL_OFFSET; if (areAllItemsLoaded || !isOffsetReached || isLoading) { diff --git a/src/modules/universal-discovery/content.create.tab.module.js b/src/modules/universal-discovery/content.create.tab.module.js index 9b6d72d3..b28c74ce 100644 --- a/src/modules/universal-discovery/content.create.tab.module.js +++ b/src/modules/universal-discovery/content.create.tab.module.js @@ -61,7 +61,7 @@ const ContentCreataTabModule = () => { const parentLocationData = clonedLoadedLocations[clonedLoadedLocations.length - 1]; parentLocationData.subitems = []; - parentLocationData.location.childCount = parentLocationData.location.childCount + 1; + parentLocationData.totalCount = parentLocationData.totalCount + 1; dispatchLoadedLocationsAction({ type: 'SET_LOCATIONS', data: clonedLoadedLocations }); dispatchSelectedLocationsAction({ type: 'ADD_SELECTED_LOCATION', location: items[0] }); diff --git a/src/modules/universal-discovery/hooks/useFindLocationsByParentLocationIdFetch.js b/src/modules/universal-discovery/hooks/useFindLocationsByParentLocationIdFetch.js index bf4adacc..8ba90875 100644 --- a/src/modules/universal-discovery/hooks/useFindLocationsByParentLocationIdFetch.js +++ b/src/modules/universal-discovery/hooks/useFindLocationsByParentLocationIdFetch.js @@ -29,8 +29,7 @@ export const useFindLocationsByParentLocationIdFetch = (locationData, { sortClau if ( !locationData.parentLocationId || locationData.collapsed || - ((locationData.location && locationData.subitems.length >= locationData.location.childCount) || - locationData.subitems.length >= limit + offset) + (locationData.subitems.length >= locationData.totalCount || locationData.subitems.length >= limit + offset) ) { dispatch({ type: 'FETCH_END', data: {} }); diff --git a/src/modules/universal-discovery/services/universal.discovery.service.js b/src/modules/universal-discovery/services/universal.discovery.service.js index 43decd5d..625cd36c 100644 --- a/src/modules/universal-discovery/services/universal.discovery.service.js +++ b/src/modules/universal-discovery/services/universal.discovery.service.js @@ -44,15 +44,17 @@ export const findLocationsByParentLocationId = ( return mappedSubitems; }); - - callback({ - location: location.Location, - version: version.Version, + const locationData = { + location: location ? location.Location : null, + version: version ? version.Version : null, + totalCount: subitems.totalCount || 4, subitems: subitemsData, bookmarked: bookmark, permissions, parentLocationId, - }); + }; + + callback(locationData); }) .catch(showErrorNotification); };