Relays are partially working now in the options options script instead of background.

This commit is contained in:
Ryan Breen
2023-01-27 23:24:29 -05:00
parent f0c5cd29dc
commit 97f706e180
3 changed files with 44 additions and 22 deletions

View File

@@ -61,9 +61,9 @@ export async function initialize() {
await getOrSetDefault('profiles', [await generateProfile()]);
}
export async function generateProfile() {
export async function generateProfile(name = 'Default') {
return {
name: 'Default',
name,
privKey: await generatePrivateKey(),
hosts: [],
relays: [],
@@ -86,6 +86,13 @@ export async function saveProfileName(index, profileName) {
await storage.set({ profiles });
}
export async function savePrivateKey(index, privateKey) {
await browser.runtime.sendMessage({
kind: 'savePrivateKey',
payload: [index, privateKey],
});
}
export async function newProfile() {
let profiles = await getProfiles();
const newProfile = await generateProfile('New Profile');
@@ -93,3 +100,15 @@ export async function newProfile() {
await storage.set({ profiles });
return profiles.length - 1;
}
export async function getRelays(profileIndex) {
let profile = await getProfile(profileIndex);
return profile.relays || [];
}
export async function saveRelays(profileIndex, relays) {
let profiles = await getProfile(profileIndex);
console.log('saving: ', relays);
profile.relays = [...relays];
await storage.set({ profiles });
}