Added prettier config. All web files (js/html) should be formatted using prettier!

This commit is contained in:
Ryan Breen
2023-01-22 22:17:07 -05:00
parent 16589e2313
commit ea3805dd02
9 changed files with 216 additions and 137 deletions

View File

@@ -1,4 +1,4 @@
import Alpine from "alpinejs";
import Alpine from 'alpinejs';
window.Alpine = Alpine;
Alpine.data('popup', () => ({
@@ -15,8 +15,8 @@ Alpine.data('popup', () => ({
confirmDelete: false,
async init() {
console.log("Initializing backend.");
await browser.runtime.sendMessage({kind: 'init'});
console.log('Initializing backend.');
await browser.runtime.sendMessage({ kind: 'init' });
this.$watch('profileIndex', async () => {
await this.setProfileIndex();
@@ -46,57 +46,71 @@ Alpine.data('popup', () => ({
// 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 browser.runtime.sendMessage({kind: 'setProfileIndex', payload: this.profileIndex});
await browser.runtime.sendMessage({
kind: 'setProfileIndex',
payload: this.profileIndex,
});
}
},
async getNsecKey() {
this.privKey = await browser.runtime.sendMessage({kind: 'getNsecKey'});
this.privKey = await browser.runtime.sendMessage({
kind: 'getNsecKey',
});
this.pristinePrivKey = this.privKey;
},
async getNpubKey() {
this.pubKey = await browser.runtime.sendMessage({kind: 'getNpubKey'});
this.pubKey = await browser.runtime.sendMessage({ kind: 'getNpubKey' });
},
async getHosts() {
this.hosts = await browser.runtime.sendMessage({kind: 'getHosts'});
this.hosts = await browser.runtime.sendMessage({ kind: 'getHosts' });
},
async getProfileNames() {
this.profileNames = await browser.runtime.sendMessage({kind: 'getProfileNames'});
this.profileNames = await browser.runtime.sendMessage({
kind: 'getProfileNames',
});
},
async getName() {
this.name = await browser.runtime.sendMessage({kind: 'getName'});
this.name = await browser.runtime.sendMessage({ kind: 'getName' });
this.pristineName = this.name;
},
async getProfileIndex() {
this.profileIndex = await browser.runtime.sendMessage({kind: 'getProfileIndex'});
this.profileIndex = await browser.runtime.sendMessage({
kind: 'getProfileIndex',
});
},
async newProfile() {
let newIndex = await browser.runtime.sendMessage({kind: 'newProfile'});
let newIndex = await browser.runtime.sendMessage({
kind: 'newProfile',
});
await this.refreshProfile();
this.profileIndex = newIndex;
},
async saveProfile() {
let {name, privKey, hosts} = this;
let profile = {name, privKey, hosts};
await browser.runtime.sendMessage({kind: 'saveProfile', payload: profile});
let { name, privKey, hosts } = this;
let profile = { name, privKey, hosts };
await browser.runtime.sendMessage({
kind: 'saveProfile',
payload: profile,
});
await this.refreshProfile();
},
async clearData() {
await browser.runtime.sendMessage({kind: 'clearData'});
await browser.runtime.sendMessage({ kind: 'clearData' });
await this.init(); // Re-initialize after clearing
this.confirmClear = false;
},
async deleteProfile() {
await browser.runtime.sendMessage({kind: 'deleteProfile'});
await browser.runtime.sendMessage({ kind: 'deleteProfile' });
await this.init();
this.confirmDelete = false;
},
@@ -104,13 +118,15 @@ Alpine.data('popup', () => ({
// Properties
get hasValidPubKey() {
return typeof(this.pubKey) === 'string' && this.pubKey.length > 0;
return typeof this.pubKey === 'string' && this.pubKey.length > 0;
},
get needsSaving() {
return (this.privKey !== this.pristinePrivKey || this.name !== this.pristineName);
}
return (
this.privKey !== this.pristinePrivKey ||
this.name !== this.pristineName
);
},
}));
Alpine.start();