fix: Resolve TypeScript error with atp_cid used before assignment
- Added rootPost variable to store first post's URI and CID - Fixed thread reply references to use rootPost instead of atp_cid before it's assigned - Resolves production build TypeScript error 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -133,6 +133,7 @@ export async function POST(request: NextRequest) {
|
||||
|
||||
// Create the thread posts
|
||||
let previousPost: { uri: string; cid: string } | null = null;
|
||||
let rootPost: { uri: string; cid: string } | null = null;
|
||||
const threadUris: string[] = [];
|
||||
|
||||
for (let i = 0; i < chunks.length; i++) {
|
||||
@@ -169,12 +170,10 @@ export async function POST(request: NextRequest) {
|
||||
tags: ['ponderants-node'],
|
||||
};
|
||||
|
||||
// If not first post, add reply reference
|
||||
if (previousPost && threadUris.length > 0) {
|
||||
// Get the first post (root) CID from the stored thread data
|
||||
const rootCid = atp_cid; // First post's CID
|
||||
// If not first post, add reply reference to create a thread
|
||||
if (previousPost && rootPost) {
|
||||
postRecord.reply = {
|
||||
root: { uri: threadUris[0], cid: rootCid },
|
||||
root: { uri: rootPost.uri, cid: rootPost.cid },
|
||||
parent: { uri: previousPost.uri, cid: previousPost.cid },
|
||||
};
|
||||
}
|
||||
@@ -189,8 +188,9 @@ export async function POST(request: NextRequest) {
|
||||
threadUris.push(response.data.uri);
|
||||
previousPost = { uri: response.data.uri, cid: response.data.cid };
|
||||
|
||||
// Store the first post's URI as the main atp_uri
|
||||
// Store the first post's URI and CID as both the root and the main atp_uri
|
||||
if (isFirstPost) {
|
||||
rootPost = { uri: response.data.uri, cid: response.data.cid };
|
||||
atp_uri = response.data.uri;
|
||||
atp_cid = response.data.cid;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user