Browse Source

removed debug messages

master
silberengel 7 months ago
parent
commit
5345d27b4c
  1. 22
      src/routes/publication/[type]/[identifier]/+page.ts

22
src/routes/publication/[type]/[identifier]/+page.ts

@ -4,17 +4,13 @@ import { fetchEventByDTag, fetchEventById, fetchEventByNaddr, fetchEventByNevent @@ -4,17 +4,13 @@ import { fetchEventByDTag, fetchEventById, fetchEventByNaddr, fetchEventByNevent
import type { NostrEvent } from "../../../../lib/utils/websocket_utils.ts";
export const load: PageLoad = async ({ params, parent }: { params: { type: string; identifier: string }; parent: any }) => {
console.debug(`[Publication Load] Page load function called with params:`, params);
const { type, identifier } = params;
console.debug(`[Publication Load] About to call parent()...`);
// Get layout data (no server-side data since SSR is disabled)
const layoutData = await parent();
console.debug(`[Publication Load] Layout data received:`, layoutData ? 'success' : 'null');
// AI-NOTE: Always fetch client-side since server-side fetch returns null for now
let indexEvent: NostrEvent | null = null;
console.debug(`[Publication Load] Fetching client-side for: ${identifier}`);
try {
// Handle different identifier types
@ -26,9 +22,7 @@ export const load: PageLoad = async ({ params, parent }: { params: { type: strin @@ -26,9 +22,7 @@ export const load: PageLoad = async ({ params, parent }: { params: { type: strin
indexEvent = await fetchEventByDTag(identifier);
break;
case 'naddr':
console.debug(`[Publication Load] Calling fetchEventByNaddr for: ${identifier}`);
indexEvent = await fetchEventByNaddr(identifier);
console.debug(`[Publication Load] fetchEventByNaddr returned:`, indexEvent ? 'success' : 'null');
break;
case 'nevent':
indexEvent = await fetchEventByNevent(identifier);
@ -36,17 +30,13 @@ export const load: PageLoad = async ({ params, parent }: { params: { type: strin @@ -36,17 +30,13 @@ export const load: PageLoad = async ({ params, parent }: { params: { type: strin
default:
error(400, `Unsupported identifier type: ${type}`);
}
console.debug(`[Publication Load] Client-side indexEvent after fetch:`, indexEvent ? 'success' : 'null');
} catch (err) {
console.error(`[Publication Load] Error fetching event client-side:`, err);
throw err;
}
if (!indexEvent) {
// AI-NOTE: Handle case where no relays are available during preloading
// This prevents 404 errors when relay stores haven't been populated yet
console.warn(`[Publication Load] Event not found for ${type}: ${identifier} - may be due to no relays available`);
// Create appropriate search link based on type
let searchParam = '';
@ -68,22 +58,11 @@ export const load: PageLoad = async ({ params, parent }: { params: { type: strin @@ -68,22 +58,11 @@ export const load: PageLoad = async ({ params, parent }: { params: { type: strin
error(404, `Event not found for ${type}: ${identifier}. href="/events?${searchParam}"`);
}
console.debug(`[Publication Load] indexEvent details:`, {
id: indexEvent.id,
kind: indexEvent.kind,
pubkey: indexEvent.pubkey,
tags: indexEvent.tags.length,
contentLength: indexEvent.content.length
});
const publicationType = indexEvent.tags.find((tag) => tag[0] === "type")?.[1] ?? "";
console.debug(`[Publication Load] publicationType:`, publicationType);
// AI-NOTE: Use proper NDK instance from layout or create one with relays
let ndk = layoutData?.ndk;
if (!ndk) {
console.debug(`[Publication Load] Layout NDK not available, creating NDK instance with relays`);
// Import NDK dynamically to avoid SSR issues
const NDK = (await import("@nostr-dev-kit/ndk")).default;
// Import initNdk to get properly configured NDK with relays
@ -97,6 +76,5 @@ export const load: PageLoad = async ({ params, parent }: { params: { type: strin @@ -97,6 +76,5 @@ export const load: PageLoad = async ({ params, parent }: { params: { type: strin
ndk, // Use minimal NDK instance
};
console.debug(`[Publication Load] Returning result:`, result);
return result;
};

Loading…
Cancel
Save