mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-02 22:32:27 +08:00
fix: revert UI and notify user when feedback submission fails (#237)
When feedback submission to the API fails, revert the optimistic UI update and show a toast notification to inform the user. Changes: - Add toast import from sonner - Change console.warn to console.error for proper logging - Add toast.error() notification when API call fails - Revert optimistic UI update by removing feedback from state Previously, feedback submission failures were completely silent. Users would see the thumbs-up/down visual feedback but their feedback was never recorded. This creates a false sense that the feedback was successfully submitted. Now users are immediately notified when submission fails and can retry their feedback.
This commit is contained in:
@@ -270,7 +270,14 @@ export function ChatMessageDisplay({
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn("Failed to log feedback:", error)
|
console.error("Failed to log feedback:", error)
|
||||||
|
toast.error("Failed to record your feedback. Please try again.")
|
||||||
|
// Revert optimistic UI update
|
||||||
|
setFeedback((prev) => {
|
||||||
|
const next = { ...prev }
|
||||||
|
delete next[messageId]
|
||||||
|
return next
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user