Skip to content

Commit

Permalink
fix(ga): add Klaus fix for pagesize
Browse files Browse the repository at this point in the history
  • Loading branch information
eouin committed Sep 6, 2024
1 parent cf30d9e commit f778d4b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
1 change: 1 addition & 0 deletions packages/webapp/src/webview/state/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,4 @@ export const getNetworkStatus = (state: AppState) => state.networkStatus;
export const getActiveScreen = (state: AppState) => state.activeScreen;
export const getProductFilters = (state: AppState) => state.selectedProductFilters;
export const getComponentFilters = (state: AppState) => state.selectedComponentFilters;
export const getPageSize = (state: AppState) => state.pageSize;
24 changes: 7 additions & 17 deletions packages/webapp/src/webview/ui/components/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,19 @@ export function App(): ReactElement {
if (!resultsContainer) {
return undefined;
}
//tree-item element height is ~100px, using 50px here to be on the safe side.
// tree-item element height is ~100px, using 50px here to be on the safe side. Header uses ~300, minimum page size is 5.
const setPageSizeByContainerHeight = (pxHeight: number): void => {
actions.setPageSize(Math.ceil(pxHeight / 50));
actions.setPageSize(Math.max(5, Math.ceil((pxHeight - 300) / 50)));
};
const resizeObserver = new ResizeObserver((entries: ResizeObserverEntry[]) => {
const containerEntry = entries.find((entry) => entry?.target?.id === 'results-container');
if (containerEntry) {
setPageSizeByContainerHeight(containerEntry.contentRect.height);
}
});
// Set initial page size
setPageSizeByContainerHeight(resultsContainer.clientHeight);
resizeObserver.observe(resultsContainer);
return () => {
if (resizeObserver) {
resizeObserver.unobserve(resultsContainer);
}

window.onresize = () => {
setPageSizeByContainerHeight(window.innerHeight);
};
setPageSizeByContainerHeight(window.innerHeight);
return undefined;
}, []);

useEffect(() => {
// appState.pageSize

const isMore =
appState.guidedAnswerTreeSearchResult.trees.length < appState.guidedAnswerTreeSearchResult.resultSize;
setHasMore(isMore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function FiltersRibbon() {
component: []
},
paging: {
responseSize: 20, //appState.pageSize,
responseSize: appState.pageSize,
offset: 0
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
getSearchQuery,
getNetworkStatus,
getActiveScreen,
getPageSize,
getProductFilters,
getComponentFilters
} from '../../../../state/reducers';
Expand All @@ -22,6 +23,7 @@ export const SearchField: React.FC = (): JSX.Element => {
const networkStatus: string = useAppSelector(getNetworkStatus);
const productFilters: string[] = useAppSelector(getProductFilters);
const componentFilters: string[] = useAppSelector(getComponentFilters);
const pageSize: number = useAppSelector(getPageSize);
const activeScreen: string = useAppSelector(getActiveScreen);
const activeSearch: string = useAppSelector(getSearchQuery);

Expand Down Expand Up @@ -70,7 +72,7 @@ export const SearchField: React.FC = (): JSX.Element => {
component: componentFilters
},
{
responseSize: 20,
responseSize: pageSize,
offset: 0
}
);
Expand Down

0 comments on commit f778d4b

Please sign in to comment.