Skip to content

Commit

Permalink
chore: add console.log and fallbacks to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed Feb 2, 2022
1 parent b76ace1 commit d61a6f9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
6 changes: 1 addition & 5 deletions packages/dnb-eufemia/src/components/pagination/Pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,7 @@ const paginationPropTypes = {

class: PropTypes.string,
className: PropTypes.string,
children: PropTypes.oneOfType([
// PropTypes.array,
PropTypes.node,
PropTypes.func,
]),
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),

on_change: PropTypes.func,
on_startup: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ export default class InfinityScroller extends React.PureComponent {
) => {
const { pageCount, endInfinity } = this.context.pagination

console.log('InfinityScroller: getNewContent', {
newPageNo,
pageCount,
})

// if "page_count" is set do not load more than that value
if (newPageNo > pageCount) {
return endInfinity()
Expand Down Expand Up @@ -200,6 +205,18 @@ export default class InfinityScroller extends React.PureComponent {
indicator_element,
} = this.context.pagination

console.log('InfinityScroller: render', {
// our states
lowerPage,
upperPage,
pageCount,
hasEndedInfinity,
parallelLoadCount,

// our props
current_page,
})

const Marker = () => (
<InteractionMarker
pageNumber={upperPage}
Expand Down Expand Up @@ -284,13 +301,20 @@ export default class InfinityScroller extends React.PureComponent {
indicator_element,
} = this.context.pagination

console.log('InfinityScroller: items.length', items.length)

// invoke startup if needed
if (!(items && items.length > 0)) {
clearTimeout(this._startupTimeout)
this._startupTimeout = setTimeout(this.startup, 1) // call startup()
return null // stop here
}

console.log(
'InfinityScroller: useMarkerOnly',
this.context.pagination.useMarkerOnly
)

if (this.context.pagination.useMarkerOnly) {
return this.handleInfinityMarker()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,19 @@ export default class PaginationProvider extends React.PureComponent {
// only used by handleInfinityMarker
if (props.useMarkerOnly) {
if (typeof state.lowerPage === 'undefined') {
state.lowerPage = state.startupPage
state.lowerPage = state.startupPage || 1
}
const cur = parseFloat(props.current_page)
if (!isNaN(cur) && cur < state.lowerPage) {
state.lowerPage = cur
}
if (typeof state.upperPage === 'undefined') {
state.upperPage =
state.startupPage + parseFloat(props.startup_count) - 1
state.startupPage + (parseFloat(props.startup_count) || 1) - 1 ||
1
}
console.log('InfinityScroller: lowerPage', state.lowerPage)
console.log('InfinityScroller: upperPage', state.upperPage)
}

// reset content, like the resetContent method
Expand Down Expand Up @@ -288,6 +291,8 @@ export default class PaginationProvider extends React.PureComponent {
}

endInfinity = () => {
console.log('InfinityScroller: endInfinity')

this.setState(
{
hasEndedInfinity: true,
Expand Down

0 comments on commit d61a6f9

Please sign in to comment.