Browse Source

refactor: import kinds from consts

master
limina1 8 months ago
parent
commit
e118c53de5
  1. 8
      src/lib/consts.ts
  2. 28
      src/lib/navigator/EventNetwork/NodeTooltip.svelte

8
src/lib/consts.ts

@ -2,7 +2,7 @@
export const wikiKind = 30818; export const wikiKind = 30818;
export const indexKind = 30040; export const indexKind = 30040;
export const zettelKinds = [30041, 30818]; export const zettelKinds = [30041, 30818, 30023];
export const communityRelays = [ export const communityRelays = [
"wss://theforest.nostr1.com", "wss://theforest.nostr1.com",
@ -29,18 +29,18 @@ export const secondaryRelays = [
export const anonymousRelays = [ export const anonymousRelays = [
"wss://freelay.sovbit.host", "wss://freelay.sovbit.host",
"wss://thecitadel.nostr1.com" "wss://thecitadel.nostr1.com",
]; ];
export const lowbandwidthRelays = [ export const lowbandwidthRelays = [
"wss://theforest.nostr1.com", "wss://theforest.nostr1.com",
"wss://thecitadel.nostr1.com", "wss://thecitadel.nostr1.com",
"wss://aggr.nostr.land" "wss://aggr.nostr.land",
]; ];
export const localRelays: string[] = [ export const localRelays: string[] = [
"wss://localhost:8080", "wss://localhost:8080",
"wss://localhost:4869" "wss://localhost:4869",
]; ];
export enum FeedType { export enum FeedType {

28
src/lib/navigator/EventNetwork/NodeTooltip.svelte

@ -9,7 +9,11 @@
import { onMount } from "svelte"; import { onMount } from "svelte";
import { getMatchingTags } from "$lib/utils/nostrUtils"; import { getMatchingTags } from "$lib/utils/nostrUtils";
import { getEventKindName } from "$lib/utils/eventColors"; import { getEventKindName } from "$lib/utils/eventColors";
import { getDisplayNameSync, replacePubkeysWithDisplayNames } from "$lib/utils/profileCache"; import {
getDisplayNameSync,
replacePubkeysWithDisplayNames,
} from "$lib/utils/profileCache";
import {indexKind, zettelKinds } from "$lib/consts";
// Component props // Component props
let { let {
@ -35,9 +39,9 @@
// Maximum content length to display // Maximum content length to display
const MAX_CONTENT_LENGTH = 200; const MAX_CONTENT_LENGTH = 200;
// Publication event kinds (text/article based) // Publication event kinds (text/article based)
const PUBLICATION_KINDS = [30040, 30041, 30818, 30023]; // Added 30023 (long-form content) const PUBLICATION_KINDS = [wikiKind, indexKind, ...zettelKinds];
/** /**
* Gets the author name from the event tags * Gets the author name from the event tags
@ -81,14 +85,14 @@
} }
return "View Publication"; return "View Publication";
} }
/** /**
* Checks if this is a publication event * Checks if this is a publication event
*/ */
function isPublicationEvent(kind: number): boolean { function isPublicationEvent(kind: number): boolean {
return PUBLICATION_KINDS.includes(kind); return PUBLICATION_KINDS.includes(kind);
} }
/** /**
* Gets the appropriate URL for the event * Gets the appropriate URL for the event
*/ */
@ -98,7 +102,7 @@
} }
return `/events?id=${node.id}`; return `/events?id=${node.id}`;
} }
/** /**
* Gets display text for the link * Gets display text for the link
*/ */
@ -238,17 +242,23 @@
{#if node.event?.content} {#if node.event?.content}
<div class="tooltip-content-preview"> <div class="tooltip-content-preview">
<span class="font-semibold">Content:</span> <span class="font-semibold">Content:</span>
<pre class="whitespace-pre-wrap">{truncateContent(node.event.content)}</pre> <pre class="whitespace-pre-wrap">{truncateContent(
node.event.content,
)}</pre>
</div> </div>
{/if} {/if}
<!-- Show some relevant tags for non-publication events --> <!-- Show some relevant tags for non-publication events -->
{#if node.event?.tags && node.event.tags.length > 0} {#if node.event?.tags && node.event.tags.length > 0}
<div class="tooltip-metadata"> <div class="tooltip-metadata">
Tags: {node.event.tags.length} Tags: {node.event.tags.length}
{#if node.event.tags.length <= 3} {#if node.event.tags.length <= 3}
{#each node.event.tags as tag} {#each node.event.tags as tag}
<span class="text-xs">· {tag[0]}{tag[1] ? `: ${tag[0] === 'p' ? getDisplayNameSync(tag[1]) : tag[1].substring(0, 20)}${tag[1].length > 20 && tag[0] !== 'p' ? '...' : ''}` : ''}</span> <span class="text-xs"
{tag[0]}{tag[1]
? `: ${tag[0] === "p" ? getDisplayNameSync(tag[1]) : tag[1].substring(0, 20)}${tag[1].length > 20 && tag[0] !== "p" ? "..." : ""}`
: ""}</span
>
{/each} {/each}
{/if} {/if}
</div> </div>

Loading…
Cancel
Save