Fix: return promise in prefs.set
This commit is contained in:
parent
67cad1176c
commit
e257ff2985
|
@ -107,7 +107,10 @@ const prefs = (() => {
|
||||||
specific: new Map(),
|
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 => {
|
.then(result => {
|
||||||
if (result.settings) {
|
if (result.settings) {
|
||||||
setAll(result.settings, true);
|
setAll(result.settings, true);
|
||||||
|
@ -234,7 +237,7 @@ const prefs = (() => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
timer = null;
|
timer = null;
|
||||||
chrome.storage.sync.set({settings: values})
|
syncSet({settings: values})
|
||||||
.then(resolve, reject);
|
.then(resolve, reject);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -143,6 +143,7 @@
|
||||||
<label>
|
<label>
|
||||||
<span>Cloud drive</span>
|
<span>Cloud drive</span>
|
||||||
<select class="cloud-name">
|
<select class="cloud-name">
|
||||||
|
<option value="none">None</option>
|
||||||
<option value="dropbox">Dropbox</option>
|
<option value="dropbox">Dropbox</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
|
|
@ -105,6 +105,9 @@ document.onclick = e => {
|
||||||
|
|
||||||
connectButton.addEventListener('click', e => {
|
connectButton.addEventListener('click', e => {
|
||||||
if (validClick(e)) {
|
if (validClick(e)) {
|
||||||
|
if (cloud.value === 'none') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
connectButton.disabled = true;
|
connectButton.disabled = true;
|
||||||
cloud.disabled = true;
|
cloud.disabled = true;
|
||||||
prefs.set('sync.enabled', cloud.value)
|
prefs.set('sync.enabled', cloud.value)
|
||||||
|
@ -124,7 +127,7 @@ document.onclick = e => {
|
||||||
.then(() => API.syncStop())
|
.then(() => API.syncStop())
|
||||||
.catch(console.error)
|
.catch(console.error)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
connectButton.enabled = true;
|
connectButton.disabled = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user