Added page for Experimental features, with NIP-26 support.

This commit is contained in:
Ryan Breen
2023-02-06 20:45:20 -05:00
parent 2aabd443e1
commit 6c83c24921
14 changed files with 363 additions and 49 deletions

View File

@@ -1,4 +1,4 @@
const DB_VERSION = 1;
const DB_VERSION = 2;
const storage = browser.storage.local;
export const RECOMMENDED_RELAYS = [
new URL('wss://relay.damus.io'),
@@ -41,6 +41,14 @@ async function migrate(version, goal) {
await storage.set({ profiles });
return version + 1;
}
if (version === 1) {
console.log('migrating to version 2.');
let profiles = await getProfiles();
profiles.forEach(profile => (profile.delegate = false));
await storage.set({ profiles });
return version + 1;
}
}
export async function getProfiles() {
@@ -98,6 +106,7 @@ export async function generateProfile(name = 'Default') {
privKey: await generatePrivateKey(),
hosts: {},
relays: [],
delegate: false,
};
}
@@ -213,3 +222,9 @@ export function validateKey(key) {
return hexMatch || b32Match;
}
export async function feature(name) {
let fname = `feature:${name}`;
let f = await browser.storage.local.get({ [fname]: false });
return f[fname];
}