rename activeProfile to profileIndex
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { generatePrivateKey, getPublicKey } from "nostr-tools";
|
||||
|
||||
const storage = browser.storage.local;
|
||||
|
||||
let profiles = [
|
||||
{name: 'Default', privKey: generatePrivateKey(), hosts: [
|
||||
{host: 'yosup.app', allowed: true},
|
||||
@@ -8,9 +10,9 @@ let profiles = [
|
||||
{name: 'Extra', privKey: generatePrivateKey(), hosts: []},
|
||||
];
|
||||
|
||||
let activeProfile = 0;
|
||||
let profileIndex = 0;
|
||||
|
||||
browser.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
||||
browser.runtime.onMessage.addListener(async (message, _sender, sendResponse) => {
|
||||
console.log(message);
|
||||
if (message.kind === 'getPubKey') {
|
||||
const privKey = getPublicKey(message.payload);
|
||||
@@ -20,7 +22,17 @@ browser.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
||||
sendResponse(privKey);
|
||||
} else if (message.kind === 'getProfiles') {
|
||||
sendResponse(profiles);
|
||||
} else if (message.kind === 'getActiveProfile') {
|
||||
sendResponse(activeProfile);
|
||||
} else if (message.kind === 'getProfileIndex') {
|
||||
sendResponse(await getProfileIndex());
|
||||
} else if (message.kind === 'setProfileIndex') {
|
||||
await setProfileIndex(message.payload);
|
||||
}
|
||||
});
|
||||
|
||||
async function getProfileIndex() {
|
||||
return await storage.get('profileIndex').profileIndex;
|
||||
}
|
||||
|
||||
async function setProfileIndex(profileIndex) {
|
||||
await storage.set({profileIndex});
|
||||
}
|
||||
Reference in New Issue
Block a user