diff --git a/CHANGELOG.md b/CHANGELOG.md index a21040f37c..d1598960ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Global config api path under `api.url` - @BartoszLiburski (#2622) - Google Tag Manager integration - @talalus (#841) - Portuguese (pt-PT) translation - @xlcnd (#2695) +- Added `syncTasks` cleanup, `elasticCacheQuota` lowered to 3096KB - @pkarw (#2729) ### Fixed - Sidebar menu wasn't possible to scroll - @PanMisza (#2627) diff --git a/config/default.json b/config/default.json index 3ebbf6e54c..d8b798c16e 100644 --- a/config/default.json +++ b/config/default.json @@ -14,7 +14,7 @@ "dynamicConfigContinueOnError": false, "dynamicConfigExclude": ["ssr", "storeViews", "entities", "localForage", "shipping", "boost", "query"], "dynamicConfigInclude": [], - "elasticCacheQuota": 4096 + "elasticCacheQuota": 3096 }, "seo": { "useUrlDispatcher": true diff --git a/core/client-entry.ts b/core/client-entry.ts index 6aa7ca76bc..f57408b5c9 100755 --- a/core/client-entry.ts +++ b/core/client-entry.ts @@ -213,11 +213,7 @@ const invokeClientEntry = async () => { // event.data.config - configuration, endpoints etc const storeView = currentStoreView() const dbNamePrefix = storeView.storeCode ? storeView.storeCode + '-' : '' - - const syncTaskCollection = new UniversalStorage(localForage.createInstance({ - name: dbNamePrefix + 'shop', - storeName: 'syncTasks' - })) + const syncTaskCollection = Vue.prototype.$db.syncTaskCollection const usersCollection = new UniversalStorage(localForage.createInstance({ name: (config.storeViews.commonCache ? '' : dbNamePrefix) + 'shop', @@ -254,7 +250,7 @@ const invokeClientEntry = async () => { mutex[id] = true // mark this task as being processed fetchQueue.push(() => { return execute(task, currentToken, currentCartId).then(executedTask => { - syncTaskCollection.setItem(executedTask.task_id.toString(), executedTask) + syncTaskCollection.removeItem(id) // remove successfully executed task from the queue mutex[id] = false }).catch(err => { mutex[id] = false diff --git a/core/lib/sync/index.ts b/core/lib/sync/index.ts index a392501986..cfa5c40a1a 100644 --- a/core/lib/sync/index.ts +++ b/core/lib/sync/index.ts @@ -76,13 +76,7 @@ function execute (task) { // not offline task /** Clear sync tasks that were not transmitted yet */ function clearNotTransmited () { const storeView = currentStoreView() - const dbNamePrefix = storeView.storeCode ? storeView.storeCode + '-' : '' - - const syncTaskCollection = new UniversalStorage(localForage.createInstance({ - name: dbNamePrefix + 'shop', - storeName: 'syncTasks', - driver: localForage[rootStore.state.config.localForage.defaultDrivers['syncTasks']] - })) + const syncTaskCollection = Vue.prototype.$db.syncTaskCollection syncTaskCollection.iterate((task, id, iterationNumber) => { if (!task.transmited) { syncTaskCollection.removeItem(id)