Show/Hide Button for private key in Options page. Move experimental page into separate sub-folder. Move delegation wizard to sub-folder. Move permission page into separate folder. Basic functional SwiftUI look for the app. Beginning to define the main app view. NavigationStack and Privacy Policy Show App Icon on main screen. Getting Started: macOS Getting Started: iPhone Getting Started: iPad Removing old default UIKit code. Added "No Thanks" toggle to the relay reminder. Clearly indicate in the Settings page when a profile is a delegated profile. Changed recommended relays to all public relays. Use x-cloak in all the places. Fix bundle display name to use capital N. Added copy button to pubkey in settings. Window default size. Updating event kind list. Allow events to be copied by clicking on them in the event log. Tweaking the colors for a more purple-ish look. Added Tips and Tricks view to native app. Move utilities modules into separate folder. Rename event_log files to event_history to escape some content blockers. Renamed Event Log to Event History in the UI as well.
92 lines
2.5 KiB
JavaScript
92 lines
2.5 KiB
JavaScript
import {
|
|
getProfileNames,
|
|
setProfileIndex,
|
|
getProfileIndex,
|
|
getRelays,
|
|
RECOMMENDED_RELAYS,
|
|
saveRelays,
|
|
initialize,
|
|
relayReminder,
|
|
toggleRelayReminder,
|
|
} from './utilities/utils';
|
|
import Alpine from 'alpinejs';
|
|
window.Alpine = Alpine;
|
|
|
|
const log = console.log;
|
|
|
|
Alpine.data('popup', () => ({
|
|
profileNames: ['Default'],
|
|
profileIndex: 0,
|
|
relayCount: 0,
|
|
showRelayReminder: true,
|
|
|
|
async init() {
|
|
log('Initializing backend.');
|
|
await initialize();
|
|
|
|
this.$watch('profileIndex', async () => {
|
|
await this.loadNames();
|
|
await this.setProfileIndex();
|
|
await this.countRelays();
|
|
await this.checkRelayReminder();
|
|
});
|
|
|
|
// Even though loadProfileIndex will immediately trigger a profile refresh, we still
|
|
// need to do an initial profile refresh first. This will pull the latest data from
|
|
// the background scripts. Specifically, this pulls the list of profile names,
|
|
// otherwise it generates a rendering error where it may not show the correct selected
|
|
// profile when first loading the popup.
|
|
await this.loadNames();
|
|
await this.loadProfileIndex();
|
|
await this.countRelays();
|
|
await this.checkRelayReminder();
|
|
},
|
|
|
|
async setProfileIndex() {
|
|
// Becauset the popup state resets every time it open, we use null as a guard. That way
|
|
// whenever the user opens the popup, it doesn't automatically reset the current profile
|
|
if (this.profileIndex !== null) {
|
|
await setProfileIndex(this.profileIndex);
|
|
}
|
|
},
|
|
|
|
async loadNames() {
|
|
this.profileNames = await getProfileNames();
|
|
},
|
|
|
|
async loadProfileIndex() {
|
|
this.profileIndex = await getProfileIndex();
|
|
},
|
|
|
|
async openOptions() {
|
|
await browser.runtime.openOptionsPage();
|
|
window.close();
|
|
},
|
|
|
|
async countRelays() {
|
|
let relays = await getRelays(this.profileIndex);
|
|
this.relayCount = relays.length;
|
|
},
|
|
|
|
async checkRelayReminder() {
|
|
this.showRelayReminder = await relayReminder();
|
|
},
|
|
|
|
async addRelays() {
|
|
let relays = RECOMMENDED_RELAYS.map(r => ({
|
|
url: r.href,
|
|
read: true,
|
|
write: true,
|
|
}));
|
|
await saveRelays(this.profileIndex, relays);
|
|
await this.countRelays();
|
|
},
|
|
|
|
async noThanks() {
|
|
await toggleRelayReminder();
|
|
this.showRelayReminder = false;
|
|
},
|
|
}));
|
|
|
|
Alpine.start();
|