diff --git a/core/client-entry.ts b/core/client-entry.ts index 6e520cdfc1..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.removeItem(executedTask.task_id.toString()) // remove successfully executed task from the queue + 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)