Skip to content

Commit

Permalink
problem: still can't get user name
Browse files Browse the repository at this point in the history
  • Loading branch information
gsovereignty committed Apr 20, 2024
1 parent af3712a commit 86e62ed
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 34 deletions.
60 changes: 31 additions & 29 deletions src/lib/components/UserDisplayName.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,56 @@
import { nip19 } from 'nostr-tools';
import { onDestroy, onMount } from 'svelte';
import { derived } from 'svelte/store';
export let pubkey: string;
let q: QueryLike;
onMount(()=>{
if (pubkey) {
onMount(() => {
if (pubkey && pubkey.length == 64) {
if (!$kind0.get(pubkey)) {
const rb = new RequestBuilder(pubkey);
rb.withFilter().authors([pubkey]).kinds([0]);
rb.withOptions({ leaveOpen: false });
q = System.Query(rb);
q.on('event', (evs) => {
if (evs.length > 0) {
kind0.update((existing) => {
for (let e of evs) {
let _existing = existing.get(e.pubkey);
if (!_existing || (_existing && _existing.created_at <= e.created_at)) {
existing.set(e.pubkey, e);
const rb = new RequestBuilder(pubkey);
rb.withFilter().authors([pubkey]).kinds([0]);
rb.withOptions({ leaveOpen: false });
q = System.Query(rb);
q.on('event', (evs) => {
if (evs.length > 0) {
kind0.update((existing) => {
for (let e of evs) {
let _existing = existing.get(e.pubkey);
if (!_existing || (_existing && _existing.created_at <= e.created_at)) {
existing.set(e.pubkey, e);
}
}
}
return existing;
});
}
});
return existing;
});
}
});
}
}
})
});
onDestroy(() => {
if (q) {
q.cancel();
}
});
let displayName = derived(kind0, ($kind0) => {
let content = $kind0.get(pubkey)?.content
let name = nip19.npubEncode(pubkey).substring(0,8)
let content = $kind0.get(pubkey)?.content;
let name = nip19.npubEncode(pubkey).substring(0, 12);
if (content) {
try {
let json = JSON.parse(content)
let json = JSON.parse(content);
if (json.Name && json.Name.length > 0) {
name = json.Name
} else if (json.display_name && json.display_name.length > 0){
name = json.display_name
name = json.Name;
} else if (json.display_name && json.display_name.length > 0) {
name = json.display_name;
} else if (json.name && json.name.length > 0) {
name = json.name;
}
} catch {}
}
return name
}
return name;
});
</script>

{$displayName}
2 changes: 1 addition & 1 deletion src/lib/snort_workers/fetch_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let count = 0
async function start(eventIDs: string[]) {
return new Promise((resolve, reject) => {
const sys = new NostrSystem({
checkSigs: true //todo: check sigs JIT on rendering
checkSigs: false //todo: check sigs JIT on rendering
// automaticOutboxModel: true,
// buildFollowGraph: true,
});
Expand Down
2 changes: 1 addition & 1 deletion src/lib/snort_workers/live_subs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let count = 0
async function start(pubkeys: string[]) {
return new Promise((resolve, reject) => {
const sys = new NostrSystem({
checkSigs: true //todo: check sigs JIT on rendering
checkSigs: false //todo: check sigs JIT on rendering
// automaticOutboxModel: true,
// buildFollowGraph: true,
});
Expand Down
2 changes: 1 addition & 1 deletion src/lib/snort_workers/master_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let workerData = new WorkerData();
let workerDataStore = writable(workerData);

const sys = new NostrSystem({
checkSigs: true
checkSigs: false
// automaticOutboxModel: true,
// buildFollowGraph: true,
});
Expand Down
2 changes: 1 addition & 1 deletion src/lib/views/messages/RenderKind1.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ onMount(() => {
alt="profile pic"
/>
<div class="grid">
<h5 class="text-gray-900 dark:text-orange-600 font-semibold leading-snug pb-1"><UserDisplayName pubkey={note.pubkey}/></h5>
<h5 class="text-gray-900 dark:text-orange-600 font-semibold leading-snug pb-1"><UserDisplayName pubkey={note.pubkey} /></h5>
<div class="grid overflow-hidden mr-2 min-w-56">
<div
class="px-3.5 py-2 bg-gray-200 dark:bg-gray-700 rounded-e-xl rounded-es-xl flex flex-col gap-2"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/views/messages/snort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { seedRelays } from "@/snort_workers/seed_relays";
import { NostrSystem, type QueryLike } from "@snort/system";
import { writable } from "svelte/store";

export const System = new NostrSystem({checkSigs: true});
export const System = new NostrSystem({checkSigs: false});
let started = false;

export async function init() {
Expand Down

0 comments on commit 86e62ed

Please sign in to comment.