From 1b2c88f92635f8039dd7cc99fcae13ed0e4f8f4f Mon Sep 17 00:00:00 2001 From: eight Date: Fri, 12 Oct 2018 03:46:51 +0800 Subject: [PATCH] Fix: no need to access db --- background/background.js | 4 +--- edit/edit.js | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/background/background.js b/background/background.js index b5e803eb..4e66bf11 100644 --- a/background/background.js +++ b/background/background.js @@ -17,14 +17,12 @@ window.API_METHODS = Object.assign(window.API_METHODS || {}, { installStyle: styleManager.installStyle, editSave: styleManager.editSave, styleExists: styleManager.styleExists, + getStyle: styleManager.get, getTabUrlPrefix() { return this.sender.tab.url.match(/^([\w-]+:\/+[^/#]+)/)[1]; }, - getStyleFromDB: id => - db.exec('get', id).then(event => event.target.result), - download(msg) { delete msg.method; return download(msg.url, msg); diff --git a/edit/edit.js b/edit/edit.js index 42fa5980..253d12ab 100644 --- a/edit/edit.js +++ b/edit/edit.js @@ -328,7 +328,7 @@ function onRuntimeMessage(request) { // code-less style from notifyAllTabs const {sections, id} = request.style; ((sections && sections[0] || {}).code === null - ? API.getStyleFromDB(id) + ? API.getStyle(id) : Promise.resolve([request.style]) ).then(([style]) => { editor.replaceStyle(style, request.codeIsUpdated); @@ -418,7 +418,7 @@ function initStyleData() { function fetchStyle() { if (id) { - return API.getStyleFromDB(id); + return API.getStyle(id); } return Promise.resolve(createEmptyStyle()); }