Update the profile information in the fields if a profile already exists.
This commit is contained in:
@@ -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