fix: address code review issues for embeds implementation
- Fix ?? to || in metadataFetcher.ts to handle empty strings from Cheerio - Fix stale embeds on message edit: delete old embeds synchronously before broadcast, then resolve new ones async (all 4 edit paths: REST+WS, msg+DM) - Revert unrelated MessageList.tsx scroll threshold change (5000 not 150) - Remove duplicate embed indexes from migrateAddIndexes (kept standalone ones)
This commit is contained in:
@@ -1007,6 +1007,9 @@ export async function dmRoutes(app: FastifyInstance): Promise<void> {
|
||||
.where(eq(schema.dmMessages.id, id))
|
||||
.run();
|
||||
|
||||
// Delete old embeds synchronously so the broadcast reflects the edit
|
||||
db.delete(schema.embeds).where(eq(schema.embeds.dmMessageId, id)).run();
|
||||
|
||||
const updated = getDmMessageWithUser(id);
|
||||
if (!updated) {
|
||||
return reply.code(500).send({ error: 'Failed to update message', statusCode: 500 });
|
||||
@@ -1025,9 +1028,9 @@ export async function dmRoutes(app: FastifyInstance): Promise<void> {
|
||||
});
|
||||
}
|
||||
|
||||
// Re-resolve embeds asynchronously after responding
|
||||
// Resolve new embeds asynchronously (old ones already deleted above)
|
||||
setImmediate(() => {
|
||||
reResolveEmbeds(id, content.trim(), msg.dmChannelId, true, null).catch(() => {});
|
||||
resolveEmbeds(id, content.trim(), msg.dmChannelId, true, null).catch(() => {});
|
||||
});
|
||||
|
||||
return reply.code(200).send(updated);
|
||||
|
||||
Reference in New Issue
Block a user