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

bugfix - revert init filters #3968

Merged
merged 4 commits into from Jan 8, 2020
Merged

bugfix - revert init filters #3968

merged 4 commits into from Jan 8, 2020

Conversation

gibkigonzo
Copy link
Collaborator

Short Description and Why It's Useful

On init load https://test.storefrontcloud.io/women/women-20 filters are missing on SSR so we get price without format.

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 Vue Storefront sites with this new feature

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

Contribution and Currently Important Rules Acceptance

Copy link
Collaborator

@pkarw pkarw left a comment

Choose a reason for hiding this comment

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

@gibkigonzo it will cause memory leak - there is a known issue with Vue.mixins and Vue.filters and memory leaks

if we're to move it out this once helper then it must be executed ONLY in CSR mode - however not sure if it won't cause another side effects blinking or CSR/SSR DOM mismatch

Reference: vuejs/vue#5089

@gibkigonzo
Copy link
Collaborator Author

I just reverted this from 1.10.5. It's wierd problem because if we call those initialization in once then filters exist on Vue prototype but there are not triggered in template. And it happens only in ssr (It's ok in csr). And same is with mixin. They are not triggered in ssr. I will try to investigate it further

@gibkigonzo
Copy link
Collaborator Author

@pkarw Problem is that we add filters once and then in price filter we import currentStoreView which returns storeView from cached module (from first request). So I've added storeView to global in SSR, we will get always newest storeView in ssr. Also removed this helper https://github.com/DivanteLtd/vue-storefront/pull/3968/files#diff-c2effc5bdc3d0e591b453db20306e6d9L82 because it's not needed anymore.

@gibkigonzo
Copy link
Collaborator Author

Or we could pass storeView to price filter (and date filter). Filters would be more pure, but we would have to pass this every time in template product.price | price(currentStoreView())

Copy link
Collaborator

@pkarw pkarw left a comment

Choose a reason for hiding this comment

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

That makes sense. I'd opt for both solutions:

  • use the global for the storeView placeholder to keep b.c.
  • use it as a filter parameter (with default value pointing to this global) - to be used in the new themes

export function currentStoreView (): StoreView {
// TODO: Change to getter all along our code
return rootStore.state.storeView
const serverStoreView = get(global, 'process.storeView', undefined)
Copy link
Contributor

Choose a reason for hiding this comment

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

what about client-side? there is no global?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

there is no global on client-side, I could use window, but I think we can stay with same behavior as it was for client

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it is in next line const clientStoreView = get(rootStore, 'state.storeView', undefined)

@andrzejewsky
Copy link
Contributor

@gibkigonzo one comment left. Is it ready?

@gibkigonzo
Copy link
Collaborator Author

@pkarw @andrzejewsky I've applied suggestion

@andrzejewsky andrzejewsky self-requested a review January 8, 2020 11:45
@andrzejewsky andrzejewsky merged commit 3246e72 into vuestorefront:develop Jan 8, 2020
This was referenced Jan 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants