From d0ff86379bb623ff49c770c6f8e2f82d3990b745 Mon Sep 17 00:00:00 2001 From: Daniel Fahlke Date: Fri, 24 May 2019 11:11:53 +0200 Subject: [PATCH 1/2] avoid increase of start property when function runs in parallel the start value in the end should always depend on the start value, it started with. Runs which happen in parallel do not affect the showed products, so they should also not affect the start value --- core/modules/catalog/components/Search.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/modules/catalog/components/Search.ts b/core/modules/catalog/components/Search.ts index 199a460935..63c0a45b68 100644 --- a/core/modules/catalog/components/Search.ts +++ b/core/modules/catalog/components/Search.ts @@ -34,11 +34,12 @@ export const Search = { makeSearch () { if (this.search !== '' && this.search !== undefined) { let query = this.buildSearchQuery(this.search) - this.start = 0 + let startValue = 0; + this.start = startValue this.readMore = true this.$store.dispatch('product/list', { query, start: this.start, size: this.size, updateState: false }).then(resp => { this.products = resp.items - this.start = this.start + this.size + this.start = startValue + this.size this.emptyResults = resp.items.length < 1 }).catch((err) => { Logger.error(err, 'components-search')() @@ -51,14 +52,15 @@ export const Search = { seeMore () { if (this.search !== '' && this.search !== undefined) { let query = this.buildSearchQuery(this.search) - this.$store.dispatch('product/list', { query, start: this.start, size: this.size, updateState: false }).then((resp) => { + let startValue = this.start; + this.$store.dispatch('product/list', { query, start: startValue, size: this.size, updateState: false }).then((resp) => { let page = Math.floor(resp.total / this.size) let exceeed = resp.total - this.size * page if (resp.start === resp.total - exceeed) { this.readMore = false } this.products = this.products.concat(resp.items) - this.start = this.start + this.size + this.start = startValue + this.size this.emptyResults = this.products.length < 1 }).catch((err) => { Logger.error(err, 'components-search')() From d83bc6f3ff171e6d7d362313080f84d13bda7fa2 Mon Sep 17 00:00:00 2001 From: Daniel Fahlke Date: Fri, 24 May 2019 11:22:05 +0200 Subject: [PATCH 2/2] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 269582e923..2a91a635e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Use event bus to emit 'application-after-init' event (#2852) - Validation of fields 'company name' and 'tax' in checkout doesn't work correctly - @dimasch (#2741) - Fixed wrong price displayed in instant checkout module - @vishal-7037 (#2884) +- Fixed Load more in Search Results not working when typed to fast - @Flyingmana (#2659, #2946) ### Changed / Improved - Changed the way to access the configuration. Currently the `rootStore.state.config` is deprecated. Please do use the `import config from 'config'` > `config` instead - @pkarw (#2649)