Fix: don't dup promisify in prefs

This commit is contained in:
eight 2018-10-14 18:09:53 +08:00
parent d4ddfcc713
commit 2aff14e213
3 changed files with 3 additions and 18 deletions

View File

@ -406,6 +406,7 @@ function onRuntimeMessage(msg, sender) {
return fn.apply(context, msg.args);
}
// FIXME: popup.js also open editor but it doesn't use this API.
function openEditor({id}) {
let url = '/edit.html';
if (id) {

View File

@ -1,3 +1,4 @@
/* global promisify */
/* exported prefs */
'use strict';
@ -179,23 +180,6 @@ const prefs = (() => {
},
};
function promisify(fn) {
return (...args) =>
new Promise((resolve, reject) => {
fn(...args, (...result) => {
if (chrome.runtime.lastError) {
reject(chrome.runtime.lastError);
} else if (result.length === 0) {
resolve(undefined);
} else if (result.length === 1) {
resolve(result[0]);
} else {
resolve(result);
}
});
});
}
function setAll(settings, synced) {
for (const [key, value] of Object.entries(settings)) {
set(key, value, synced);

View File

@ -151,11 +151,11 @@
<link rel="stylesheet" href="manage/config-dialog.css">
<script src="manage/config-dialog.js"></script>
<script src="js/promisify.js"></script>
<script src="js/dom.js"></script>
<script src="js/messaging.js"></script>
<script src="js/localization.js"></script>
<script src="js/prefs.js"></script>
<script src="js/promisify.js"></script>
<script src="js/msg.js"></script>
<script src="content/apply.js"></script>