docs(changeset): Added refs and exports, isEmpty
This commit is contained in:
@@ -7,6 +7,7 @@ import { useGridlerStore } from './GridlerStore';
|
||||
export const Pager = React.memo(() => {
|
||||
const [
|
||||
setState,
|
||||
getState,
|
||||
glideref,
|
||||
visiblePages,
|
||||
//_visibleArea,
|
||||
@@ -16,6 +17,7 @@ export const Pager = React.memo(() => {
|
||||
hasLocalData,
|
||||
] = useGridlerStore((s) => [
|
||||
s.setState,
|
||||
s.getState,
|
||||
s._glideref,
|
||||
s._visiblePages,
|
||||
//s._visibleArea,
|
||||
@@ -38,10 +40,10 @@ export const Pager = React.memo(() => {
|
||||
if (!glideref) {
|
||||
return;
|
||||
}
|
||||
if (hasLocalData) {
|
||||
//using local data, no need to load pages
|
||||
return;
|
||||
}
|
||||
// if (hasLocalData) {
|
||||
// //using local data, no need to load pages
|
||||
// return;
|
||||
// }
|
||||
const firstPage = Math.max(0, Math.floor(visiblePages.y / pageSize));
|
||||
const lastPage = Math.floor((visiblePages.y + visiblePages.height) / pageSize);
|
||||
//const upperPage = pageSize * firstPage;
|
||||
@@ -57,7 +59,10 @@ export const Pager = React.memo(() => {
|
||||
// );
|
||||
|
||||
for (const page of range(firstPage, lastPage + 1, 1)) {
|
||||
loadPage(page);
|
||||
loadPage(page).then(() => {
|
||||
const pg = getState('_page_data')?.[0] ?? {};
|
||||
setState('isEmpty', pg && pg.length > 0);
|
||||
});
|
||||
}
|
||||
}, [loadPage, pageSize, visiblePages, glideref, _loadingList, hasLocalData]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user