On the options screen, profile names are now loaded directly from the store.

This commit is contained in:
Ryan Breen
2023-01-27 17:34:47 -05:00
parent 621e8b358b
commit 6171b9395c

View File

@@ -1,4 +1,5 @@
import Alpine from 'alpinejs'; import Alpine from 'alpinejs';
import { getProfileNames } from './utils';
const RECOMMENDED_RELAYS = [ const RECOMMENDED_RELAYS = [
new URL('wss://relay.damus.io'), new URL('wss://relay.damus.io'),
@@ -46,7 +47,7 @@ Alpine.data('options', () => ({
}, },
async refreshProfile() { async refreshProfile() {
await this.getProfileNames(); await this.loadProfileNames();
await this.getProfileName(); await this.getProfileName();
await this.getNsec(); await this.getNsec();
await this.getNpub(); await this.getNpub();
@@ -56,18 +57,15 @@ Alpine.data('options', () => ({
// Profile functions // Profile functions
async getProfileNames() { async loadProfileNames() {
this.profileNames = await browser.runtime.sendMessage({ this.profileNames = await getProfileNames();
kind: 'getProfileNames',
});
}, },
async getProfileName() { async getProfileName() {
this.profileName = await browser.runtime.sendMessage({ let names = await getProfileNames();
kind: 'getNameForProfile', let name = names[this.profileIndex];
payload: this.profileIndex, this.profileName = name;
}); this.pristineProfileName = name;
this.pristineProfileName = this.profileName;
}, },
async getActiveIndex() { async getActiveIndex() {
@@ -80,7 +78,7 @@ Alpine.data('options', () => ({
let newIndex = await browser.runtime.sendMessage({ let newIndex = await browser.runtime.sendMessage({
kind: 'newProfile', kind: 'newProfile',
}); });
await this.getProfileNames(); await this.loadProfileNames();
this.profileIndex = newIndex; this.profileIndex = newIndex;
}, },
@@ -105,7 +103,7 @@ Alpine.data('options', () => ({
kind: 'saveProfileName', kind: 'saveProfileName',
payload: [this.profileIndex, this.profileName], payload: [this.profileIndex, this.profileName],
}); });
await this.getProfileNames(); await this.loadProfileNames();
await this.refreshProfile(); await this.refreshProfile();
}, },