Refactor chat page useEffect organization and improve compose intent handling

Reorganizes useEffect hooks in chat/page.tsx to follow a helper-functions-first structure, improving readability and maintainability. Adds error handling and user feedback for compose intent, preventing UI flash while processing. In send/route.ts, ensures remote user handles are fully qualified and adds debug logging. Temporarily disables key caching in keys/route.ts to address development key mismatches.
This commit is contained in:
Christopher
2026-01-28 07:37:27 -08:00
parent a21af87144
commit 93a587f185
3 changed files with 148 additions and 126 deletions
+7 -6
View File
@@ -46,12 +46,13 @@ export async function GET(request: NextRequest) {
),
});
if (cached) {
console.log('[Chat Keys GET] Found cached remote key');
return NextResponse.json({
publicKey: cached.publicKey,
});
}
// DEBUG: Force refresh for now to fix development key mismatches
// if (cached) {
// console.log('[Chat Keys GET] Found cached remote key');
// return NextResponse.json({
// publicKey: cached.publicKey,
// });
// }
// If not in cache, try to resolve DID to a node
console.log('[Chat Keys GET] resolving DID to node...');
+8 -1
View File
@@ -114,11 +114,18 @@ export async function POST(request: NextRequest) {
});
if (!registryEntry) {
console.error('Recipient DID not found in registry:', recipientDid);
return NextResponse.json({ error: 'Recipient not found in registry' }, { status: 404 });
}
const targetDomain = registryEntry.nodeDomain;
const targetHandle = registryEntry.handle; // e.g. user@domain
// Ensure handle is fully qualified for remote users
let targetHandle = registryEntry.handle;
if (!targetHandle.includes('@') && targetDomain) {
targetHandle = `${targetHandle}@${targetDomain}`;
}
console.log(`[Remote Send] Sending to ${targetHandle} at ${targetDomain}`);
// 2. Prepare Payload
const messageData = {