Fix: no need to access db

This commit is contained in:
eight 2018-10-12 03:46:51 +08:00
parent a8131fc9c5
commit 1b2c88f926
2 changed files with 3 additions and 5 deletions

View File

@ -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);

View File

@ -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());
}