Review: Use generic getMarketplaceEntities instead

This commit is contained in:
Mikko Koski 2018-01-18 10:33:08 +02:00
parent e2813fb346
commit c8994c11ed
2 changed files with 3 additions and 17 deletions

View file

@ -7,7 +7,7 @@ import { connect } from 'react-redux';
import { types as sdkTypes } from '../../util/sdkLoader';
import { createSlug } from '../../util/urlHelpers';
import { propTypes } from '../../util/types';
import { getOwnListingsById } from '../../ducks/marketplaceData.duck';
import { getMarketplaceEntities } from '../../ducks/marketplaceData.duck';
import { manageDisableScrolling, isScrollingDisabled } from '../../ducks/UI.duck';
import { stripeAccountClearError, createStripeAccount } from '../../ducks/user.duck';
import { EditListingWizard, NamedRedirect, Page } from '../../components';
@ -216,7 +216,8 @@ const mapStateToProps = state => {
const fetchInProgress = createStripeAccountInProgress;
const getListing = id => {
const listings = getOwnListingsById(state, [id]);
const listings = getMarketplaceEntities(state, [{ id, type: 'ownListing' }]);
return listings.length === 1 ? listings[0] : null;
};
return {

View file

@ -46,21 +46,6 @@ export const getListingsById = (state, listingIds) => {
}
};
/**
* Get the denormalised ownListing entities with the given IDs
*
* @param {Object} state the full Redux store
* @param {Array<UUID>} listingIds listing IDs to select from the store
*/
export const getOwnListingsById = (state, listingIds) => {
const { entities } = state.marketplaceData;
try {
return denormalisedEntities(entities, 'ownListing', listingIds);
} catch (e) {
return [];
}
};
/**
* Get the denormalised entities from the given entity references.
*