mirror of
https://github.com/ItsVipra/ProToots
synced 2024-11-22 11:33:03 +00:00
add option reset button, default options
This commit is contained in:
parent
0b8ed6c238
commit
14ae2a1bca
2 changed files with 27 additions and 6 deletions
|
@ -44,6 +44,7 @@
|
|||
<div class="footer">
|
||||
<button type="submit">Save</button>
|
||||
<button id="resetbutton" type="button">Reset Cache</button>
|
||||
<button id="defaultSettings" type="button">Default settings</button>
|
||||
<a target="_blank" href="https://github.com/ItsVipra/ProToots"
|
||||
>More info / help on Github</a
|
||||
>
|
||||
|
|
|
@ -14,13 +14,19 @@ function saveOptions(e) {
|
|||
}
|
||||
|
||||
function restoreOptions() {
|
||||
function setCurrentChoice(result) {
|
||||
async function setCurrentChoice(result) {
|
||||
console.log(result);
|
||||
if (Object.keys(result).length == 0) {
|
||||
console.log(result);
|
||||
await defaultOptions();
|
||||
} else {
|
||||
document.querySelector("#logging").checked = result.logging || false;
|
||||
document.querySelector("#status").checked = result.statusVisibility || false;
|
||||
document.querySelector("#notification").checked = result.notificationVisibility || false;
|
||||
document.querySelector("#account").checked = result.accountVisibility || false;
|
||||
document.querySelector("#conversation").checked = result.conversationVisibility || false;
|
||||
}
|
||||
}
|
||||
|
||||
function onError(err) {
|
||||
error(`Error: ${err}`);
|
||||
|
@ -30,8 +36,22 @@ function restoreOptions() {
|
|||
getting.then(setCurrentChoice, onError);
|
||||
}
|
||||
|
||||
async function defaultOptions() {
|
||||
await storage.sync.set({
|
||||
logging: false,
|
||||
statusVisibility: true,
|
||||
notificationVisibility: true,
|
||||
accountVisibility: true,
|
||||
conversationVisibility: false,
|
||||
});
|
||||
restoreOptions();
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", restoreOptions);
|
||||
document.querySelector("form").addEventListener("submit", saveOptions);
|
||||
document.querySelector("#resetbutton").addEventListener("click", async () => {
|
||||
await storage.local.clear();
|
||||
});
|
||||
document.querySelector("#defaultSettings").addEventListener("click", async () => {
|
||||
await defaultOptions();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue