Skip to content

Commit

Permalink
Merge pull request #4326 from tloncorp/po/tlon-3428-delay-on-sending-…
Browse files Browse the repository at this point in the history
…followup-messages

chat: fix issue with delay on sending followup messages
  • Loading branch information
patosullivan authored Jan 13, 2025
2 parents d4c5e11 + 29cdce1 commit f4e21b6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/shared/src/store/postActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,19 @@ export async function sendPost({
}
// optimistic update
// TODO: make author available more efficiently
logger.crumb('get author');
const author = await db.getContact({ id: authorId });
logger.crumb('build pending post');
const cachePost = db.buildPendingPost({
authorId,
author,
channel,
content,
metadata,
});
logger.crumb('insert channel posts');
sync.handleAddPost(cachePost);
logger.crumb('done optimistic update');
try {
logger.crumb('sending post to backend');
await api.sendPost({
Expand All @@ -57,7 +61,9 @@ export async function sendPost({
metadata: metadata,
sentAt: cachePost.sentAt,
});
await sync.syncChannelMessageDelivery({ channelId: channel.id });
logger.crumb('sent post to backend, syncing channel message delivery');
sync.syncChannelMessageDelivery({ channelId: channel.id });
logger.crumb('done sending post');
} catch (e) {
logger.crumb('failed to send post');
console.error('Failed to send post', e);
Expand Down

0 comments on commit f4e21b6

Please sign in to comment.