diff --git a/CHANGELOG.md b/CHANGELOG.md index d969a82b..d481b8ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ way to update this template, but currently, we follow a pattern: ## Upcoming version 2019-XX-XX +- [add] Use sparse fields on InboxPage query to reduce data load. + [#1067](https://github.com/sharetribe/flex-template-web/pull/1067) + - NOTE: if you need more fields on `InboxPage`, you need to add those to `loadData` function. - [add] Use sparse fields on SearchPage to reduce data load. [#1066](https://github.com/sharetribe/flex-template-web/pull/1066) - NOTE: if you need more fields on `ListingCard` than title, price and geolocation - you need to diff --git a/src/containers/InboxPage/InboxPage.duck.js b/src/containers/InboxPage/InboxPage.duck.js index 3e94cedc..7f485066 100644 --- a/src/containers/InboxPage/InboxPage.duck.js +++ b/src/containers/InboxPage/InboxPage.duck.js @@ -94,6 +94,14 @@ export const loadData = (params, search) => (dispatch, getState, sdk) => { only: onlyFilter, lastTransitions: TRANSITIONS, include: ['provider', 'provider.profileImage', 'customer', 'customer.profileImage', 'booking'], + 'fields.transaction': [ + 'lastTransition', + 'lastTransitionedAt', + 'transitions', + 'payinTotal', + 'payoutTotal', + ], + 'fields.user': ['profile.displayName', 'profile.abbreviatedName'], 'fields.image': ['variants.square-small', 'variants.square-small2x'], page, per_page: INBOX_PAGE_SIZE, diff --git a/src/util/types.js b/src/util/types.js index 8fc152ad..c008cccd 100644 --- a/src/util/types.js +++ b/src/util/types.js @@ -339,7 +339,7 @@ propTypes.transaction = shape({ id: propTypes.uuid.isRequired, type: propTypes.value('transaction').isRequired, attributes: shape({ - createdAt: instanceOf(Date).isRequired, + createdAt: instanceOf(Date), lastTransitionedAt: instanceOf(Date).isRequired, lastTransition: oneOf(TRANSITIONS).isRequired, @@ -357,7 +357,7 @@ propTypes.transaction = shape({ lineTotal: propTypes.money.isRequired, reversal: bool.isRequired, }) - ).isRequired, + ), transitions: arrayOf(propTypes.transition).isRequired, }), booking: propTypes.booking,