Update the profile information in the fields if a profile already exists.

This commit is contained in:
Your Name
2025-12-01 14:28:49 -04:00
parent 9285f8e583
commit 5152bb6e5e
2 changed files with 75 additions and 2 deletions

49
Trash/trash.json Normal file
View 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
}

View File

@@ -32,7 +32,7 @@
<div class="tabs"> <div class="tabs">
<div class="tab active" data-tab="tab1">Post</div> <div class="tab active" data-tab="tab1">Post</div>
<div class="tab" data-tab="tab2">Reply</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>
<div class="tab-content active" id="tab1"> <div class="tab-content active" id="tab1">
<h3>Post</h3> <h3>Post</h3>
@@ -49,7 +49,7 @@
</div> </div>
<div class="tab-content" id="tab3"> <div class="tab-content" id="tab3">
<h3>Create Profile</h3> <h3>Create/Edit Profile</h3>
<label for="name">Name:</label> <label for="name">Name:</label>
<textarea id="name" placeholder="Enter your name..."></textarea> <textarea id="name" placeholder="Enter your name..."></textarea>
<label for="about">About:</label> <label for="about">About:</label>
@@ -132,6 +132,11 @@
// Show corresponding content // Show corresponding content
const tabId = tab.getAttribute('data-tab'); const tabId = tab.getAttribute('data-tab');
document.getElementById(tabId).classList.add('active'); 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 bounceCounter = 0;
let discoveredThrowers = []; let discoveredThrowers = [];
let userRelays = []; let userRelays = [];
let userProfileData = null; // Store loaded profile data
// Initialize NOSTR_LOGIN_LITE // Initialize NOSTR_LOGIN_LITE
async function initializeApp() { async function initializeApp() {
@@ -229,6 +235,7 @@
if (events.length > 0) { if (events.length > 0) {
console.log('SUCCESS', 'Profile event received'); console.log('SUCCESS', 'Profile event received');
const profile = JSON.parse(events[0].content); const profile = JSON.parse(events[0].content);
userProfileData = profile; // Store profile data globally
displayProfile(profile); displayProfile(profile);
} else { } else {
console.log('INFO', 'No profile found'); console.log('INFO', 'No profile found');
@@ -256,6 +263,23 @@
console.log('SUCCESS', `Profile displayed: ${name}`); 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 // Load user's NIP-65 relay list
async function loadUserRelayList() { async function loadUserRelayList() {
if (!userPubkey) return []; if (!userPubkey) return [];