Disable the Save button, enabled after a change to indicate that save needs to be done.

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

View File

@@ -33,7 +33,7 @@
<div class="buttons">
<button @click="visibleKey = !visibleKey" x-text="visibleKey ? 'Hide' : 'Show'"></button>
<button @click="await saveProfile()">Save</button>
<button @click="await saveProfile()" :disabled="!needsSaving">Save</button>
<button @click="confirmClear = true" x-show="!confirmClear">Clear Data</button>
<button @click="await clearData()" x-show="confirmClear">Confirm Clear</button>
</div>

View File

@@ -4,8 +4,10 @@ window.Alpine = Alpine;
Alpine.data('popup', () => ({
privKey: '',
pubKey: '',
pristinePrivKey: '',
hosts: [],
name: '',
pristineName: '',
profileNames: ['Default'],
profileIndex: 0,
visibleKey: false,
@@ -50,12 +52,11 @@ Alpine.data('popup', () => ({
async getNsecKey() {
this.privKey = await browser.runtime.sendMessage({kind: 'getNsecKey'});
console.log('privKey: ', this.privKey);
this.pristinePrivKey = this.privKey;
},
async getNpubKey() {
this.pubKey = await browser.runtime.sendMessage({kind: 'getNpubKey'});
console.log('pubKey: ', this.pubKey);
},
async getHosts() {
@@ -64,17 +65,15 @@ Alpine.data('popup', () => ({
async getProfileNames() {
this.profileNames = await browser.runtime.sendMessage({kind: 'getProfileNames'});
console.log('Profile Names: ', this.profileNames);
},
async getName() {
this.name = await browser.runtime.sendMessage({kind: 'getName'});
console.log('Name: ', this.name);
this.pristineName = this.name;
},
async getProfileIndex() {
this.profileIndex = await browser.runtime.sendMessage({kind: 'getProfileIndex'});
console.log('Profile Index: ', this.profileIndex);
},
async newProfile() {
@@ -107,6 +106,10 @@ Alpine.data('popup', () => ({
get hasValidPubKey() {
return typeof(this.pubKey) === 'string' && this.pubKey.length > 0;
},
get needsSaving() {
return (this.privKey !== this.pristinePrivKey || this.name !== this.pristineName);
}
}));