forked from nostr/nostrweb
settings: document code on when exactly the pubkey is regenerated
The pubkey should not always be regenerated when a privatekey is pasted. The reason is that on paste event is fired before the privateKeyInput value is updated. Added code comments on when the condition passes and should be save to re-generate the pubkey.
parent
d8f71b74ec
commit
0047c0bdc0
|
@ -613,10 +613,10 @@ privateKeyInput.addEventListener('paste', (event) => {
|
|||
if (pubKeyInput.value || !event.clipboardData) {
|
||||
return;
|
||||
}
|
||||
if (privateKeyInput.value === '' || (
|
||||
privateKeyInput.selectionStart === 0
|
||||
if (privateKeyInput.value === '' || ( // either privatekey field is empty
|
||||
privateKeyInput.selectionStart === 0 // or the whole text is selected and replaced with the clipboard
|
||||
&& privateKeyInput.selectionEnd === privateKeyInput.value.length
|
||||
)) {
|
||||
)) { // only generate the pubkey if no data other than the text from clipboard will be used
|
||||
try {
|
||||
pubKeyInput.value = getPublicKey(event.clipboardData.getData('text'));
|
||||
} catch(err) {} // settings form will call validKeys on input and display the error
|
||||
|
|
Loading…
Reference in New Issue