Fix: return promise in prefs.set

This commit is contained in:
eight 2019-09-30 18:56:26 +08:00
parent 67cad1176c
commit e257ff2985
3 changed files with 10 additions and 3 deletions

View File

@ -107,7 +107,10 @@ const prefs = (() => {
specific: new Map(),
};
const initializing = promisify(chrome.storage.sync.get.bind(chrome.storage.sync))('settings')
const syncSet = promisify(chrome.storage.sync.set.bind(chrome.storage.sync));
const syncGet = promisify(chrome.storage.sync.get.bind(chrome.storage.sync));
const initializing = syncGet('settings')
.then(result => {
if (result.settings) {
setAll(result.settings, true);
@ -234,7 +237,7 @@ const prefs = (() => {
return new Promise((resolve, reject) => {
setTimeout(() => {
timer = null;
chrome.storage.sync.set({settings: values})
syncSet({settings: values})
.then(resolve, reject);
});
});

View File

@ -143,6 +143,7 @@
<label>
<span>Cloud drive</span>
<select class="cloud-name">
<option value="none">None</option>
<option value="dropbox">Dropbox</option>
</select>
</label>

View File

@ -105,6 +105,9 @@ document.onclick = e => {
connectButton.addEventListener('click', e => {
if (validClick(e)) {
if (cloud.value === 'none') {
return;
}
connectButton.disabled = true;
cloud.disabled = true;
prefs.set('sync.enabled', cloud.value)
@ -124,7 +127,7 @@ document.onclick = e => {
.then(() => API.syncStop())
.catch(console.error)
.then(() => {
connectButton.enabled = true;
connectButton.disabled = false;
});
}
});