Skip to content

Commit

Permalink
Merge branch 'main' into fix-imodel-sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
arome authored Nov 4, 2024
2 parents 6818c9a + f6f2e60 commit 6cbeeae
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/apps/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@itwin/create-imodel-react": "^2.0.0",
"@itwin/delete-imodel-react": "^2.0.0",
"@itwin/delete-itwin-react": "^2.0.0",
"@itwin/imodel-browser-react": "~2.0.1",
"@itwin/imodel-browser-react": "~2.0.2",
"@itwin/itwinui-react": "^2.12.18",
"@itwin/manage-versions-react": "~2.0.0",
"@itwin/storybook-auth-addon": "^0.1.0",
Expand Down
12 changes: 12 additions & 0 deletions packages/modules/imodel-browser/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
{
"name": "@itwin/imodel-browser-react",
"entries": [
{
"version": "2.0.2",
"tag": "@itwin/imodel-browser-react_v2.0.2",
"date": "Mon, 04 Nov 2024 21:47:34 GMT",
"comments": {
"patch": [
{
"comment": "fix list not loading extra content when reaching the bottom"
}
]
}
},
{
"version": "2.0.1",
"tag": "@itwin/imodel-browser-react_v2.0.1",
Expand Down
9 changes: 8 additions & 1 deletion packages/modules/imodel-browser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Change Log - @itwin/imodel-browser-react

This log was last generated on Mon, 16 Sep 2024 18:48:30 GMT and should not be manually modified.
This log was last generated on Mon, 04 Nov 2024 21:47:34 GMT and should not be manually modified.

## 2.0.2
Mon, 04 Nov 2024 21:47:34 GMT

### Patches

- fix list not loading extra content when reaching the bottom

## 2.0.1
Mon, 16 Sep 2024 18:48:30 GMT
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/imodel-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@itwin/imodel-browser-react",
"description": "Components that let the user browse the iModels of a context and select one.",
"repository": "https://github.com/iTwin/admin-components-react/tree/main/packages/modules/imodel-browser",
"version": "2.0.1",
"version": "2.0.2",
"main": "cjs/index.js",
"module": "esm/index.js",
"types": "cjs/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export const IModelGrid = ({
sortOptions: sort,
searchText,
maxCount,
viewMode,
});

const iModels = React.useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import React, { useEffect, useMemo } from "react";
import React from "react";

import {
ApiOverrides,
DataStatus,
IModelFull,
IModelSortOptions,
ViewType,
} from "../../types";
import { _getAPIServer } from "../../utils/_apiOverrides";
import { useIModelSort } from "./useIModelSort";
Expand All @@ -20,6 +21,7 @@ export interface IModelDataHookOptions {
apiOverrides?: ApiOverrides<IModelFull[]>;
searchText?: string | undefined;
maxCount?: number;
viewMode?: ViewType;
}
const PAGE_SIZE = 100;

Expand All @@ -30,6 +32,7 @@ export const useIModelData = ({
apiOverrides,
searchText,
maxCount,
viewMode,
}: IModelDataHookOptions) => {
const sortType = sortOptions?.sortType === "name" ? "name" : undefined; //Only available sort by API at the moment.
const sortDescending = sortOptions?.descending;
Expand All @@ -39,8 +42,9 @@ export const useIModelData = ({
const [page, setPage] = React.useState(0);
const [morePages, setMorePages] = React.useState(true);
const fetchMore = React.useCallback(() => {
setPage(page + 1);
}, [page]);
viewMode === "cells" && setStatus(DataStatus.Fetching);
status !== DataStatus.Fetching && setPage((page) => page + 1);
}, [status, viewMode]);

React.useEffect(() => {
// If sort changes but we already have all the data,
Expand Down Expand Up @@ -103,9 +107,10 @@ export const useIModelData = ({
const searching = searchText?.trim() ? `&$search=${searchText}` : "";

const abortController = new AbortController();
const url = `${_getAPIServer(
apiOverrides
)}/imodels/${selection}${sorting}${paging}${searching}`;
const url = `${_getAPIServer({
data: apiOverrides?.data,
serverEnvironmentPrefix: apiOverrides?.serverEnvironmentPrefix,
})}/imodels/${selection}${sorting}${paging}${searching}`;

const makeFetchRequest = async () => {
const options: RequestInit = {
Expand Down Expand Up @@ -153,7 +158,7 @@ export const useIModelData = ({
};
}, [
accessToken,
apiOverrides,
apiOverrides?.serverEnvironmentPrefix,
apiOverrides?.data,
morePages,
page,
Expand Down

0 comments on commit 6cbeeae

Please sign in to comment.