From 3f480f0a183cbcb26c61bbd54b71ecb55b9decc0 Mon Sep 17 00:00:00 2001 From: eight Date: Thu, 8 Nov 2018 16:41:56 +0800 Subject: [PATCH] Fix: putMany returns a list of ids --- background/style-manager.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/background/style-manager.js b/background/style-manager.js index 01c92231..a8946485 100644 --- a/background/style-manager.js +++ b/background/style-manager.js @@ -139,11 +139,16 @@ const styleManager = (() => { .then(newData => handleSave(newData, 'import')); } - function importMany(datas) { - return db.exec('putMany', datas) - .then(events => - Promise.all(events.map(event => handleSave(event.target.result, 'import'))) - ); + function importMany(items) { + return db.exec('putMany', items) + .then(events => { + for (let i = 0; i < items.length; i++) { + if (!items[i].id) { + items[i].id = events[i].target.result; + } + } + return Promise.all(items.map(i => handleSave(i, 'import'))); + }); } function installStyle(data, reason = null) {