From 15e45217987fc7460e21e09670f0510dfda4d7c0 Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Thu, 14 Sep 2017 21:13:30 +0300 Subject: [PATCH 1/3] profileImage to listing and tx relationships added and Avatar changed to bigger --- src/components/Avatar/Avatar.js | 5 ++++- src/containers/InboxPage/InboxPage.duck.js | 8 +++++++- .../ListingPage/ListingPage.duck.js | 2 +- src/containers/OrderPage/OrderPage.duck.js | 5 ++++- src/containers/SalePage/SalePage.duck.js | 20 +++++++++++++++++-- 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/components/Avatar/Avatar.js b/src/components/Avatar/Avatar.js index 48ff31cc..aaf2f97b 100644 --- a/src/components/Avatar/Avatar.js +++ b/src/components/Avatar/Avatar.js @@ -21,7 +21,10 @@ const Avatar = props => { rootClassName={css.avatarImage} alt={displayName} image={avatarUser.profileImage} - nameSet={[{ name: 'square-xlarge', size: '1x' }, { name: 'square-xlarge2x', size: '2x' }]} + nameSet={[ + { name: 'square-xlarge2x', size: '1x' }, + { name: 'square-xlarge4x', size: '2x' }, + ]} /> ); diff --git a/src/containers/InboxPage/InboxPage.duck.js b/src/containers/InboxPage/InboxPage.duck.js index 3c2a36ab..daba0363 100644 --- a/src/containers/InboxPage/InboxPage.duck.js +++ b/src/containers/InboxPage/InboxPage.duck.js @@ -90,7 +90,13 @@ export const loadData = (params, search) => const apiQueryParams = { only: onlyFilter, - include: ['provider', 'customer', 'booking'], + include: [ + 'provider', + 'provider.profileImage', + 'customer', + 'customer.profileImage', + 'booking', + ], page, per_page: INBOX_PAGE_SIZE, }; diff --git a/src/containers/ListingPage/ListingPage.duck.js b/src/containers/ListingPage/ListingPage.duck.js index 12ece99f..7230fa28 100644 --- a/src/containers/ListingPage/ListingPage.duck.js +++ b/src/containers/ListingPage/ListingPage.duck.js @@ -45,7 +45,7 @@ export const showListing = listingId => dispatch(showListingRequest(listingId)); dispatch(fetchCurrentUser()); return sdk.listings - .show({ id: listingId, include: ['author', 'images'] }) + .show({ id: listingId, include: ['author', 'author.profileImage', 'images'] }) .then(data => { dispatch(addMarketplaceEntities(data)); return data; diff --git a/src/containers/OrderPage/OrderPage.duck.js b/src/containers/OrderPage/OrderPage.duck.js index 4eaf7ae7..0f5c2d2a 100644 --- a/src/containers/OrderPage/OrderPage.duck.js +++ b/src/containers/OrderPage/OrderPage.duck.js @@ -57,7 +57,10 @@ export const fetchOrder = id => txResponse = response; const listingId = listingRelationship(response).id; - return sdk.listings.show({ id: listingId, include: ['author', 'images'] }); + return sdk.listings.show({ + id: listingId, + include: ['author', 'author.profileImage', 'images'], + }); }) .then(response => { dispatch(addMarketplaceEntities(txResponse)); diff --git a/src/containers/SalePage/SalePage.duck.js b/src/containers/SalePage/SalePage.duck.js index c9fbf02b..d04a6a56 100644 --- a/src/containers/SalePage/SalePage.duck.js +++ b/src/containers/SalePage/SalePage.duck.js @@ -91,11 +91,27 @@ export const fetchSale = id => let txResponse = null; return sdk.transactions - .show({ id, include: ['customer', 'provider', 'listing', 'booking'] }, { expand: true }) + .show( + { + id, + include: [ + 'customer', + 'customer.profileImage', + 'provider', + 'provider.profileImage', + 'listing', + 'booking', + ], + }, + { expand: true } + ) .then(response => { txResponse = response; const listingId = listingRelationship(response).id; - return sdk.listings.show({ id: listingId, include: ['author', 'images'] }); + return sdk.listings.show({ + id: listingId, + include: ['author', 'author.profileImage', 'images'], + }); }) .then(response => { dispatch(addMarketplaceEntities(txResponse)); From 96b1ddaaec69af76dd54e7d9e592ca3197d3c2a6 Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Thu, 14 Sep 2017 21:21:53 +0300 Subject: [PATCH 2/3] Update tests --- src/containers/ListingPage/ListingPage.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/containers/ListingPage/ListingPage.test.js b/src/containers/ListingPage/ListingPage.test.js index edcceabc..e2663488 100644 --- a/src/containers/ListingPage/ListingPage.test.js +++ b/src/containers/ListingPage/ListingPage.test.js @@ -52,7 +52,7 @@ describe('ListingPage', () => { return showListing(id)(dispatch, null, sdk).then(data => { expect(data).toEqual(response); - expect(show.mock.calls).toEqual([[{ id, include: ['author', 'images'] }]]); + expect(show.mock.calls).toEqual([[{ id, include: ['author', 'author.profileImage', 'images'] }]]); expect(dispatch.mock.calls).toEqual([ [showListingRequest(id)], [expect.anything()], // fetchCurrentUser() call @@ -76,7 +76,7 @@ describe('ListingPage', () => { }, e => { expect(e).toEqual(error); - expect(show.mock.calls).toEqual([[{ id, include: ['author', 'images'] }]]); + expect(show.mock.calls).toEqual([[{ id, include: ['author', 'author.profileImage', 'images'] }]]); expect(dispatch.mock.calls).toEqual([ [showListingRequest(id)], [expect.anything()], // fetchCurrentUser() call From 9a8642b752d8edb0cd6668d6e920704cd2a1075d Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Thu, 14 Sep 2017 22:03:50 +0300 Subject: [PATCH 3/3] Change comments from current user fetches since profileImage wasn't added to attributes --- src/components/Avatar/Avatar.js | 2 -- src/containers/ProfileSettingsPage/ProfileSettingsPage.duck.js | 3 +-- src/ducks/user.duck.js | 3 +-- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/components/Avatar/Avatar.js b/src/components/Avatar/Avatar.js index aaf2f97b..2af17ce4 100644 --- a/src/components/Avatar/Avatar.js +++ b/src/components/Avatar/Avatar.js @@ -12,8 +12,6 @@ const Avatar = props => { const avatarUser = ensureUser(user); const { displayName, abbreviatedName } = avatarUser.attributes.profile; - // TODO this is a temporary avatar fix for currentUser's profile data. - // Avatar images should be included to all user's attributes in the future. if (avatarUser.profileImage && avatarUser.profileImage.id) { return (
diff --git a/src/containers/ProfileSettingsPage/ProfileSettingsPage.duck.js b/src/containers/ProfileSettingsPage/ProfileSettingsPage.duck.js index 560b3886..1440460e 100644 --- a/src/containers/ProfileSettingsPage/ProfileSettingsPage.duck.js +++ b/src/containers/ProfileSettingsPage/ProfileSettingsPage.duck.js @@ -133,8 +133,7 @@ export const updateProfile = actionPayload => { .then(response => { dispatch(updateProfileSuccess(response)); - // Temporary denormalization for profileImage - // Profile image will be included to users + // Include profile image to denormalized user entity const currentUserId = response.data.data.id; const entities = updatedEntities({}, response.data); const denormalised = denormalisedEntities(entities, 'current-user', [currentUserId]); diff --git a/src/ducks/user.duck.js b/src/ducks/user.duck.js index 9a6b10b6..90dbe822 100644 --- a/src/ducks/user.duck.js +++ b/src/ducks/user.duck.js @@ -321,8 +321,7 @@ export const fetchCurrentUser = () => return sdk.currentUser .show({ include: ['profileImage'] }) .then(response => { - // Temporary denormalization for profileImage - // Profile image will be included to users + // Include profile image to denormalized user entity const currentUserId = response.data.data.id; const entities = updatedEntities({}, response.data); const denormalised = denormalisedEntities(entities, 'current-user', [currentUserId]);