Update the profile information in the fields if a profile already exists.
This commit is contained in:
49
Trash/trash.json
Normal file
49
Trash/trash.json
Normal file
@@ -0,0 +1,49 @@
|
||||
Reply to a post from Primal
|
||||
|
||||
{
|
||||
"kind": 1,
|
||||
"created_at": 1763420960,
|
||||
"content": "From Primal.",
|
||||
"pubkey": "8ff74724ed641b3c28e5a86d7c5cbc49c37638ace8c6c38935860e7a5eedde0e",
|
||||
"id": "555c77e419c6f34d1d36b6baf36489c5eb17d829645c940fc996d90c26df59a1",
|
||||
"tags": [
|
||||
[
|
||||
"e",
|
||||
"ac50dd87901863590d577fb9080ab294b8dd1b6b10563e9733d5bad817c735db",
|
||||
"wss://nos.lol",
|
||||
"root"
|
||||
],
|
||||
[
|
||||
"p",
|
||||
"8ff74724ed641b3c28e5a86d7c5cbc49c37638ace8c6c38935860e7a5eedde0e"
|
||||
],
|
||||
[
|
||||
"r",
|
||||
"wss://nostr.mom/"
|
||||
],
|
||||
[
|
||||
"r",
|
||||
"wss://relay.laantungir.net/"
|
||||
]
|
||||
],
|
||||
"sig": "5ab8f7b43e972e2089ebc95f68c49cace183832a3f867801a85c689ce6797eaa52a60ba07847212019fc2361ffca276c74f9cd69402095c6c783faac2c827bde"
|
||||
}
|
||||
|
||||
|
||||
Reply to post from proposed superball builder change.
|
||||
|
||||
{
|
||||
"id": "56e6dadc32afe11f13e83fcf8107ea8a819e4a96232d64eacafd10370224e685",
|
||||
"sig": "3766102783acfc7654f134b1dc5fd716e89e154fc81a96c7f60d20a867e5b52919cdfa7a01151550880e4e8a2945ef05feb43c022bbd7761724ded8308254b1d",
|
||||
"kind": 1,
|
||||
"tags": [
|
||||
[
|
||||
"e",
|
||||
"ac50dd87901863590d577fb9080ab294b8dd1b6b10563e9733d5bad817c735db",
|
||||
"root"
|
||||
]
|
||||
],
|
||||
"pubkey": "8ff74724ed641b3c28e5a86d7c5cbc49c37638ace8c6c38935860e7a5eedde0e",
|
||||
"content": "Yeah, it is a great night.",
|
||||
"created_at": 1763420892
|
||||
}
|
||||
@@ -32,7 +32,7 @@
|
||||
<div class="tabs">
|
||||
<div class="tab active" data-tab="tab1">Post</div>
|
||||
<div class="tab" data-tab="tab2">Reply</div>
|
||||
<div class="tab" data-tab="tab3">Create Profile</div>
|
||||
<div class="tab" data-tab="tab3">Create/Edit Profile</div>
|
||||
</div>
|
||||
<div class="tab-content active" id="tab1">
|
||||
<h3>Post</h3>
|
||||
@@ -49,7 +49,7 @@
|
||||
</div>
|
||||
|
||||
<div class="tab-content" id="tab3">
|
||||
<h3>Create Profile</h3>
|
||||
<h3>Create/Edit Profile</h3>
|
||||
<label for="name">Name:</label>
|
||||
<textarea id="name" placeholder="Enter your name..."></textarea>
|
||||
<label for="about">About:</label>
|
||||
@@ -132,6 +132,11 @@
|
||||
// Show corresponding content
|
||||
const tabId = tab.getAttribute('data-tab');
|
||||
document.getElementById(tabId).classList.add('active');
|
||||
|
||||
// If tab3 (Create/Edit Profile) is activated, populate form with existing profile data
|
||||
if (tabId === 'tab3' && userProfileData) {
|
||||
populateProfileForm(userProfileData);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -144,6 +149,7 @@
|
||||
let bounceCounter = 0;
|
||||
let discoveredThrowers = [];
|
||||
let userRelays = [];
|
||||
let userProfileData = null; // Store loaded profile data
|
||||
|
||||
// Initialize NOSTR_LOGIN_LITE
|
||||
async function initializeApp() {
|
||||
@@ -229,6 +235,7 @@
|
||||
if (events.length > 0) {
|
||||
console.log('SUCCESS', 'Profile event received');
|
||||
const profile = JSON.parse(events[0].content);
|
||||
userProfileData = profile; // Store profile data globally
|
||||
displayProfile(profile);
|
||||
} else {
|
||||
console.log('INFO', 'No profile found');
|
||||
@@ -256,6 +263,23 @@
|
||||
console.log('SUCCESS', `Profile displayed: ${name}`);
|
||||
}
|
||||
|
||||
// Populate profile form with existing profile data
|
||||
function populateProfileForm(profile) {
|
||||
if (!profile) return;
|
||||
|
||||
// Populate each field with existing data if available
|
||||
document.getElementById('name').value = profile.name || '';
|
||||
document.getElementById('about').value = profile.about || '';
|
||||
document.getElementById('profile-pic').value = profile.picture || '';
|
||||
document.getElementById('display-name').value = profile.display_name || profile.displayName || '';
|
||||
document.getElementById('website').value = profile.website || '';
|
||||
document.getElementById('banner').value = profile.banner || '';
|
||||
document.getElementById('nip05').value = profile.nip05 || '';
|
||||
document.getElementById('lud16').value = profile.lud16 || '';
|
||||
|
||||
console.log('INFO', 'Profile form populated with existing data');
|
||||
}
|
||||
|
||||
// Load user's NIP-65 relay list
|
||||
async function loadUserRelayList() {
|
||||
if (!userPubkey) return [];
|
||||
|
||||
Reference in New Issue
Block a user