fix: incorrect media appearance after reaction
This commit is contained in:
@@ -83,6 +83,12 @@ func (h *apiHandler) writeMessageWithReactions(w http.ResponseWriter, r *http.Re
|
||||
return
|
||||
}
|
||||
msgs := []messageJSON{toMessageJSON(msg)}
|
||||
if msg.MediaID != nil {
|
||||
if m, err := h.store.GetMediaByID(r.Context(), *msg.MediaID); err == nil {
|
||||
md := toMediaJSON(m)
|
||||
msgs[0].Media = &md
|
||||
}
|
||||
}
|
||||
reactions, err := h.store.ReactionsForMessages(r.Context(), []int64{msgID})
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, "internal server error")
|
||||
|
||||
@@ -263,12 +263,17 @@ export default function ChatApp({ user }: ChatAppProps) {
|
||||
const updated = mine
|
||||
? await api.removeReaction(message.conversation_id, message.id, emoji)
|
||||
: await api.addReaction(message.conversation_id, message.id, emoji)
|
||||
upsert(updated)
|
||||
patchMessage(message.id, (current) => ({
|
||||
...current,
|
||||
...updated,
|
||||
media: updated.media ?? current.media,
|
||||
reactions: updated.reactions,
|
||||
}))
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
},
|
||||
[upsert, user.id],
|
||||
[patchMessage, user.id],
|
||||
)
|
||||
|
||||
const sendTyping = useCallback(
|
||||
|
||||
Reference in New Issue
Block a user