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:
Jannis Braun
2026-03-20 23:58:06 +01:00
parent dcdf10c5de
commit ff2decded5
6 changed files with 30 additions and 23 deletions
+5 -2
View File
@@ -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);