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

@@ -40,6 +40,12 @@ browser.runtime.onMessage.addListener(async (message, _sender, sendResponse) =>
let newIndex = await newProfile();
sendResponse(newIndex);
break;
case 'saveProfile':
await saveProfile(message.payload);
break;
case 'clearData':
await browser.storage.local.clear();
break;
default:
break;
}
@@ -109,4 +115,11 @@ async function newProfile() {
profiles.push(newProfile);
await storage.set({profiles});
return profiles.length - 1;
}
async function saveProfile(profile) {
let index = await getProfileIndex();
let profiles = await get('profiles');
profiles[index] = profile;
await storage.set({profiles});
}