Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [1.11.2] - UNRELEASED

### Added
- Add `isBackRoute` that informs if user returns to route, skip loading products for category if he does - @gibkigonzo (issue#4066)

### Changed / Improved
- optimizations - improved prefetch strategy - @gibkigonzo (#4080)

Expand All @@ -16,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix possibility to add same SKU with different custom options to the cart - @Michal-Dziedzinski (#3595)
- Fix `calculateProductTax` to find matching tax rules from ES for current product - @DylannCordel (#4056)
- Set `totals` in products in cart always in reactive way - @psmyrek (#4079)
- Add currentRoute to url module and return cached requests - @gibkigonzo (pr#4077, issue#4066)

## [1.11.1] - 2020.02.05

Expand Down Expand Up @@ -52,7 +56,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix v-model not working in BaseRadioButton - @lukeromanowicz (#4035)
- always keep filters values as array of object - @gibkigonzo (#4045)
- Fix ecosystem config to work with ts-node - @andrzejewsky (#3981)
- Add currentRoute to url module and return cached requests - @gibkigonzo (#4045)

## [1.11.0] - 2019.12.20

Expand Down
4 changes: 2 additions & 2 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -449,15 +449,15 @@
"i18n": {
"defaultCountry": "US",
"defaultLanguage": "EN",
"availableLocale": ["en-US","de-DE","fr-FR","es-ES","nl-NL", "ja-JP", "ru-RU", "it-IT", "pt-BR", "pl-PL", "cs-CZ"],
"availableLocale": ["en-US"],
"defaultLocale": "en-US",
"currencyCode": "USD",
"currencySign": "$",
"priceFormat": "{sign}{amount}",
"dateFormat": "HH:mm D/M/YYYY",
"fullCountryName": "United States",
"fullLanguageName": "English",
"bundleAllStoreviewLanguages": true
"bundleAllStoreviewLanguages": false
},
"expireHeaders": {
"default": "30d",
Expand Down
2 changes: 1 addition & 1 deletion core/client-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const invokeClientEntry = async () => {
return next()
}

store.dispatch('url/setCurrentRoute', to)
store.dispatch('url/setCurrentRoute', {to, from})

Promise.all(matched.map((c: any) => { // TODO: update me for mixins support
const components = c.mixins && globalConfig.ssr.executeMixedinAsyncData ? Array.from(c.mixins) : []
Expand Down
7 changes: 5 additions & 2 deletions core/modules/url/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SearchQuery from '@vue-storefront/core/lib/search/searchQuery'
import { preProcessDynamicRoutes, normalizeUrlPath, parametrizeRouteData, getFallbackRouteData } from '../helpers'
import { removeStoreCodeFromRoute, currentStoreView, localizedDispatcherRouteName } from '@vue-storefront/core/lib/multistore'
import storeCodeFromRoute from '@vue-storefront/core/lib/storeCodeFromRoute'
import isEqual from 'lodash-es/isEqual'

// it's a good practice for all actions to return Promises with effect of their execution
export const actions: ActionTree<UrlState, any> = {
Expand Down Expand Up @@ -94,7 +95,9 @@ export const actions: ActionTree<UrlState, any> = {
}
}
},
setCurrentRoute ({ commit }, payload) {
commit(types.SET_CURRENT_ROUTE, payload)
setCurrentRoute ({ commit, state }, {to, from} = {}) {
commit(types.SET_CURRENT_ROUTE, to)
commit(types.IS_BACK_ROUTE, isEqual(state.prevRoute, state.currentRoute) && state.currentRoute.path !== from.path)
commit(types.SET_PREV_ROUTE, from)
}
}
3 changes: 2 additions & 1 deletion core/modules/url/store/getters.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const getters = {
getCurrentRoute: (state) => state.currentRoute
getCurrentRoute: (state) => state.currentRoute,
isBackRoute: (state) => state.isBackRoute
}
2 changes: 2 additions & 0 deletions core/modules/url/store/mutation-types.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export const REGISTER_MAPPING = 'URL/REGISTER_MAPPING'
export const SET_CURRENT_ROUTE = 'URL/SET_CURRENT_ROUTE'
export const SET_PREV_ROUTE = 'URL/SET_PREV_ROUTE'
export const IS_BACK_ROUTE = 'URL/IS_BACK_ROUTE'
6 changes: 6 additions & 0 deletions core/modules/url/store/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@ export const mutations: MutationTree<any> = {
},
[types.SET_CURRENT_ROUTE] (state, payload = {}) {
state.currentRoute = omit(payload, ['matched'])
},
[types.SET_PREV_ROUTE] (state, payload = {}) {
state.prevRoute = omit(payload, ['matched'])
},
[types.IS_BACK_ROUTE] (state, payload) {
state.isBackRoute = payload
}
}
4 changes: 3 additions & 1 deletion core/modules/url/store/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ import { UrlState } from '../types/UrlState'

export const state: UrlState = {
dispatcherMap: {},
currentRoute: {}
currentRoute: {},
prevRoute: {},
isBackRoute: false
}
4 changes: 3 additions & 1 deletion core/modules/url/types/UrlState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ import { LocalizedRoute } from '@vue-storefront/core/lib/types'
// It's a good practice is to name this interface accordingly to the KET (for example mailchimpState)
export interface UrlState {
dispatcherMap: { [path: string]: LocalizedRoute},
currentRoute: Partial<Route>
currentRoute: Partial<Route>,
prevRoute: Partial<Route>,
isBackRoute: boolean
}
2 changes: 1 addition & 1 deletion core/server-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default async context => {
if (!matchedComponents.length || !matchedComponents[0]) {
return reject(new HttpError('No components matched', 404)) // TODO - don't redirect if already on page-not-found
}
store.dispatch('url/setCurrentRoute', router.currentRoute)
store.dispatch('url/setCurrentRoute', { to: router.currentRoute })
Promise.all(matchedComponents.map((Component: any) => {
const components = Component.mixins ? Array.from(Component.mixins) : []
union(components, [Component]).map(SubComponent => {
Expand Down
4 changes: 3 additions & 1 deletion src/themes/default/pages/Category.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ const composeInitialPageState = async (store, route, forceLoad = false) => {
const filters = getSearchOptionsFromRouteParams(route.params)
const cachedCategory = store.getters['category-next/getCategoryFrom'](route.path)
const currentCategory = cachedCategory && !forceLoad ? cachedCategory : await store.dispatch('category-next/loadCategory', { filters })
await store.dispatch('category-next/loadCategoryProducts', {route, category: currentCategory, pageSize: THEME_PAGE_SIZE})
if (!store.getters['url/isBackRoute']) {
await store.dispatch('category-next/loadCategoryProducts', {route, category: currentCategory, pageSize: THEME_PAGE_SIZE})
}
const breadCrumbsLoader = store.dispatch('category-next/loadCategoryBreadcrumbs', { category: currentCategory, currentRouteName: currentCategory.name, omitCurrent: true })

if (isServer) await breadCrumbsLoader
Expand Down