Fixed name display
This commit is contained in:
@@ -459,7 +459,7 @@ class FloatingTab {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Create a SimplePool instance for querying
|
// Create a SimplePool instance for querying
|
||||||
const pool = new window.NostrTools.nip46.SimplePool();
|
const pool = new window.NostrTools.SimplePool();
|
||||||
|
|
||||||
// Query for kind 0 (user metadata) events
|
// Query for kind 0 (user metadata) events
|
||||||
const events = await pool.querySync(relays, {
|
const events = await pool.querySync(relays, {
|
||||||
@@ -482,9 +482,27 @@ class FloatingTab {
|
|||||||
const profile = JSON.parse(latestEvent.content);
|
const profile = JSON.parse(latestEvent.content);
|
||||||
console.log('FloatingTab: Parsed profile:', profile);
|
console.log('FloatingTab: Parsed profile:', profile);
|
||||||
|
|
||||||
// Return relevant profile fields
|
// Find the best name from any key containing "name" (case-insensitive)
|
||||||
|
let bestName = null;
|
||||||
|
const nameKeys = Object.keys(profile).filter(key =>
|
||||||
|
key.toLowerCase().includes('name') &&
|
||||||
|
typeof profile[key] === 'string' &&
|
||||||
|
profile[key].trim().length > 0
|
||||||
|
);
|
||||||
|
|
||||||
|
if (nameKeys.length > 0) {
|
||||||
|
// Find the shortest name value
|
||||||
|
bestName = nameKeys
|
||||||
|
.map(key => profile[key].trim())
|
||||||
|
.reduce((shortest, current) =>
|
||||||
|
current.length < shortest.length ? current : shortest
|
||||||
|
);
|
||||||
|
console.log('FloatingTab: Found name keys:', nameKeys, 'selected:', bestName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return relevant profile fields with the best name
|
||||||
return {
|
return {
|
||||||
name: profile.name || null,
|
name: bestName,
|
||||||
display_name: profile.display_name || null,
|
display_name: profile.display_name || null,
|
||||||
about: profile.about || null,
|
about: profile.about || null,
|
||||||
picture: profile.picture || null,
|
picture: profile.picture || null,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
* Two-file architecture:
|
* Two-file architecture:
|
||||||
* 1. Load nostr.bundle.js (official nostr-tools bundle)
|
* 1. Load nostr.bundle.js (official nostr-tools bundle)
|
||||||
* 2. Load nostr-lite.js (this file - NOSTR_LOGIN_LITE library with CSS-only themes)
|
* 2. Load nostr-lite.js (this file - NOSTR_LOGIN_LITE library with CSS-only themes)
|
||||||
* Generated on: 2025-09-16T19:47:40.071Z
|
* Generated on: 2025-09-16T22:12:00.192Z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Verify dependencies are loaded
|
// Verify dependencies are loaded
|
||||||
@@ -2323,7 +2323,7 @@ class FloatingTab {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Create a SimplePool instance for querying
|
// Create a SimplePool instance for querying
|
||||||
const pool = new window.NostrTools.nip46.SimplePool();
|
const pool = new window.NostrTools.SimplePool();
|
||||||
|
|
||||||
// Query for kind 0 (user metadata) events
|
// Query for kind 0 (user metadata) events
|
||||||
const events = await pool.querySync(relays, {
|
const events = await pool.querySync(relays, {
|
||||||
@@ -2346,9 +2346,27 @@ class FloatingTab {
|
|||||||
const profile = JSON.parse(latestEvent.content);
|
const profile = JSON.parse(latestEvent.content);
|
||||||
console.log('FloatingTab: Parsed profile:', profile);
|
console.log('FloatingTab: Parsed profile:', profile);
|
||||||
|
|
||||||
// Return relevant profile fields
|
// Find the best name from any key containing "name" (case-insensitive)
|
||||||
|
let bestName = null;
|
||||||
|
const nameKeys = Object.keys(profile).filter(key =>
|
||||||
|
key.toLowerCase().includes('name') &&
|
||||||
|
typeof profile[key] === 'string' &&
|
||||||
|
profile[key].trim().length > 0
|
||||||
|
);
|
||||||
|
|
||||||
|
if (nameKeys.length > 0) {
|
||||||
|
// Find the shortest name value
|
||||||
|
bestName = nameKeys
|
||||||
|
.map(key => profile[key].trim())
|
||||||
|
.reduce((shortest, current) =>
|
||||||
|
current.length < shortest.length ? current : shortest
|
||||||
|
);
|
||||||
|
console.log('FloatingTab: Found name keys:', nameKeys, 'selected:', bestName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return relevant profile fields with the best name
|
||||||
return {
|
return {
|
||||||
name: profile.name || null,
|
name: bestName,
|
||||||
display_name: profile.display_name || null,
|
display_name: profile.display_name || null,
|
||||||
about: profile.about || null,
|
about: profile.about || null,
|
||||||
picture: profile.picture || null,
|
picture: profile.picture || null,
|
||||||
|
|||||||
Reference in New Issue
Block a user