Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix adding unconfigured products to compare & optimize fetching homepage data #3512

Conversation

lukeromanowicz
Copy link
Contributor

fix adding unconfigured products to compare, optimize fetching data on homepage, remove unused cool bags code

Related issues

closes #3293

Which environment this relates to

Check your case. In case of any doubts please read about Release Cycle

  • Test version (https://test.storefrontcloud.io) - this is a new feature or improvement for Vue Storefront. I've created branch from develop branch and want to merge it back to develop
  • RC version (https://next.storefrontcloud.io) - this is a stabilisation fix for Release Candidate of Vue Storefront. I've created branch from release branch and want to merge it back to release
  • Stable version (https://demo.storefrontcloud.io) - this is an important fix for current stable version. I've created branch from hotfix or master branch and want to merge it back to hotfix

Upgrade Notes and Changelog

  • No upgrade steps required (100% backward compatibility and no breaking changes)
  • I've updated the Upgrade notes and Changelog on how to port existing VS sites with this new feature

IMPORTANT NOTICE - Remember to update CHANGELOG.md with description of your change

Contribution and currently important rules acceptance

@lukeromanowicz lukeromanowicz added the vs-hackathon Tasks for the Hackathon label Sep 6, 2019
Copy link
Collaborator

@patzick patzick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just small changes from me :) And please update changelog.

Love that store for the homepage is typically on theme part! I'd be voting for removing rest of queries from config like bestSellers and move them directly to actions or as action parameters. It's easier for developer to modify and find them. But it's not for this PR, just leaving this here ;D

export const homepageStore = {
namespaced: true,
state: {
new_collection: []
},
actions: {
fetchNewCollection ({ commit, dispatch }) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fetchNewCollection ({ commit, dispatch }) {
async fetchNewCollection ({ commit, dispatch }) {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please apply this one as well, all actions should return a promise by default

fetchNewCollection ({ commit, dispatch }) {
const newProductsQuery = prepareQuery({ queryConfig: 'newProducts' })

dispatch('product/list', {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please just change this to async/await

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patzick awaits are usually slower, that's why I avoid them. Dispatch should be returned though, I give you that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukeromanowicz we use babel to transpile to ES5 anyway, async/await highly increase readability and it's a convention we agreed to use.

Btw. please show me the studies about performance difference, you mentioned here, it's very interesting :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also would like to see such studies since all I ever read was saying it's still a microtask under the hood and just syntax sugar for Promises ;)

It can be slower only if you don't know how it works (not concurrently) and expect multiple await to run simultaneously but it's exactly the same with Promises

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -70,9 +66,6 @@ export default {
everythingNewCollection () {
return this.$store.state.homepage.new_collection
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be perfect to add a getter for newCollection in store and use it here:)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right 👍 I guess I can refactor that part as well.

Copy link
Collaborator

@patzick patzick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just these two changes with fetchNewCollection

export const homepageStore = {
namespaced: true,
state: {
new_collection: []
},
actions: {
fetchNewCollection ({ commit, dispatch }) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please apply this one as well, all actions should return a promise by default

@patzick patzick mentioned this pull request Sep 13, 2019
11 tasks
Copy link
Collaborator

@filrak filrak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're missing changelog and update notes for updated property name

Lukasz Romanowicz added 3 commits September 13, 2019 15:20
@pkarw pkarw merged commit 9270c0a into vuestorefront:develop Sep 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vs-hackathon Tasks for the Hackathon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants