Update how assignment of general.enableClipboardPopups works (#583)

This commit is contained in:
toasted-nutbread 2020-05-30 16:24:51 -04:00 committed by GitHub
parent 976a200ffc
commit ce7f9dd09a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,25 +36,16 @@ class ClipboardPopupsController {
}
async _onEnableClipboardPopupsChanged(e) {
const enableClipboardPopups = e.target.checked;
const options = await this._settingsController.getOptionsMutable();
const checkbox = e.currentTarget;
let value = checkbox.checked;
if (enableClipboardPopups) {
options.general.enableClipboardPopups = await new Promise((resolve) => {
chrome.permissions.request(
{permissions: ['clipboardRead']},
(granted) => {
if (!granted) {
this._checkbox.checked = false;
}
resolve(granted);
}
);
if (value) {
value = await new Promise((resolve) => {
chrome.permissions.request({permissions: ['clipboardRead']}, resolve);
});
} else {
options.general.enableClipboardPopups = false;
checkbox.checked = value;
}
await this._settingsController.save();
await this._settingsController.setProfileSetting('general.enableClipboardPopups', value);
}
}