saving data works, refreshes the UI, and also added an option to clear the storage from the UI

This commit is contained in:
Ryan Breen
2023-01-15 23:18:47 -05:00
parent 3315e2ee3c
commit 72c0c5fa98
3 changed files with 30 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ Alpine.data('popup', () => ({
profileNames: ['Default'],
profileIndex: 0,
visibleKey: false,
confirmClear: false,
async init() {
console.log("Initializing backend.");
@@ -74,6 +75,19 @@ Alpine.data('popup', () => ({
this.profileIndex = newIndex;
},
async saveProfile() {
let {name, privKey, hosts} = this;
let profile = {name, privKey, hosts};
await browser.runtime.sendMessage({kind: 'saveProfile', payload: profile});
await this.refreshProfile();
},
async clearData() {
await browser.runtime.sendMessage({kind: 'clearData'});
await this.init(); // Re-initialize after clearing
this.confirmClear = false;
},
// Properties
get hasValidPubKey() {