Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.

Commit 2f19e5a

Browse files
authored
Merge pull request #1696 from pkarw/develop
Minor fixes
2 parents 6c70b8f + d3004fb commit 2f19e5a

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

core/client-entry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ router.onReady(() => {
9494
})
9595
if (c.asyncData) {
9696
c.asyncData({ store, route: to }).then(result => { // always execute the asyncData() from the top most component first
97-
console.log('Top-most asyncData executed')
97+
console.debug('Top-most asyncData executed')
9898
_ssrHydrateSubcomponents(components, next, to)
9999
}).catch(next)
100100
} else {

core/i18n/resource/i18n/en-US.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,4 +354,5 @@
354354
"Allow notification about the order","Allow notification about the order"
355355
"Extension developers would like to thank you for placing an order!","Extension developers would like to thank you for placing an order!"
356356
"most you may purchase","most you may purchase"
357-
"have as many","have as many"
357+
"have as many","have as many"
358+
"Compare products","Compare products"

core/server-entry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default context => {
6464
})
6565
if (Component.asyncData) {
6666
Component.asyncData({ store, route: router.currentRoute }).then((result) => { // always execute the asyncData() from the top most component first
67-
console.log('Top-most asyncData executed')
67+
console.debug('Top-most asyncData executed')
6868
_ssrHydrateSubcomponents(components, store, router, resolve, reject, app, context)
6969
}).catch((err) => {
7070
_commonErrorHandler(err, reject)

core/store/lib/search.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ function search (elasticQuery) {
5858
},
5959
body: JSON.stringify(elasticQuery.body)
6060
}).then(resp => { return resp.json() }).catch(err => {
61-
throw new Error(err)
61+
if (err.message.indexOf('fetch') >= 0 || !isOnline()) {
62+
console.error('Offline mode ' + err.message)
63+
} else {
64+
throw new Error(err)
65+
}
6266
})
6367
}
6468
/**
@@ -69,7 +73,11 @@ function search (elasticQuery) {
6973
*/
7074
function _handleEsResult (resp, start = 0, size = 50): ESResponse {
7175
if (resp == null) {
72-
throw new Error('Invalid ES result - null not exepcted')
76+
if (isOnline()) {
77+
throw new Error('Invalid ES result - null not exepcted')
78+
} else {
79+
return null // empty result but not exception raised - we're in offline mode
80+
}
7381
}
7482
if (resp.hasOwnProperty('hits')) {
7583
return {
@@ -166,13 +174,16 @@ export function quickSearchByQuery ({ query, start = 0, size = 50, entityType =
166174

167175
search(esQuery).then((resp) => { // we're always trying to populate cache - when online
168176
const res = _handleEsResult(resp, start, size)
169-
cache.setItem(cacheKey, res).catch((err) => { console.error('Cannot store cache for ' + cacheKey + ', ' + err) })
170-
if (!servedFromCache) { // if navigator onLine == false means ES is unreachable and probably this will return false; sometimes returned false faster than indexedDb cache returns result ...
171-
console.debug('Result from ES for ' + cacheKey + ' (' + entityType + '), ms=' + (new Date().getTime() - benchmarkTime.getTime()))
172-
res.cache = false
173-
res.noresults = false
174-
res.offline = false
175-
resolve(res)
177+
178+
if (res) { // otherwise it can be just a offline mode
179+
cache.setItem(cacheKey, res).catch((err) => { console.error('Cannot store cache for ' + cacheKey + ', ' + err) })
180+
if (!servedFromCache) { // if navigator onLine == false means ES is unreachable and probably this will return false; sometimes returned false faster than indexedDb cache returns result ...
181+
console.debug('Result from ES for ' + cacheKey + ' (' + entityType + '), ms=' + (new Date().getTime() - benchmarkTime.getTime()))
182+
res.cache = false
183+
res.noresults = false
184+
res.offline = false
185+
resolve(res)
186+
}
176187
}
177188
}).catch(err => {
178189
reject(err)

core/store/modules/user/actions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ const actions: ActionTree<UserState, RootState> = {
196196
context.commit(types.USER_INFO_LOADED, res)
197197
context.dispatch('setUserGroup', res)
198198
Vue.prototype.$bus.$emit('user-after-loggedin', res)
199-
context.dispatch('cart/userAfterLoggedin')
199+
rootStore.dispatch('cart/userAfterLoggedin')
200200

201201
resolve(res)
202202
resolvedFromCache = true
@@ -222,7 +222,7 @@ const actions: ActionTree<UserState, RootState> = {
222222
}
223223
if (!resolvedFromCache && resp.resultCode === 200) {
224224
Vue.prototype.$bus.$emit('user-after-loggedin', resp.result)
225-
context.dispatch('cart/userAfterLoggedin')
225+
rootStore.dispatch('cart/userAfterLoggedin')
226226
resolve(resp)
227227
} else {
228228
resolve(null)

0 commit comments

Comments
 (0)