added sendingFeedback check to send-feedback#84
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements a feedback submission debounce mechanism to prevent duplicate submissions and bumps the package version to 15.0.3.
- Adds a
sendingFeedbackflag to prevent concurrent feedback submissions - Implements a 1-second delay before allowing subsequent feedback submissions
- Applies code formatting improvements (spacing in catch blocks and indentation)
Reviewed Changes
Copilot reviewed 2 out of 12 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/GleapFrameManager.js | Adds debounce logic with sendingFeedback flag and 1-second timeout to prevent duplicate feedback submissions; includes code formatting fixes |
| package.json | Bumps version from 15.0.2 to 15.0.3 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| setTimeout(() => { | ||
| this.sendingFeedback = false; | ||
| }, 1000); |
There was a problem hiding this comment.
The sendingFeedback flag is reset in the success handler before the feedback-sent message is sent. If the user closes the widget or navigates away immediately after sending feedback, the flag may reset while the operation is still in progress. Consider resetting the flag after all success-related operations complete, or move the timeout to encompass the entire success flow.
| setTimeout(() => { | ||
| this.sendingFeedback = false; | ||
|
|
||
| this.sendMessage({ | ||
| name: "feedback-sending-failed", | ||
| data: "Something went wrong, please try again.", | ||
| }); | ||
| GleapEventManager.notifyEvent("error-while-sending"); |
There was a problem hiding this comment.
The error handling is delayed by 1 second before notifying the user of the failure. This creates a poor user experience where the UI appears unresponsive for 1 second after an error occurs. The sendingFeedback flag reset should be delayed for debouncing, but the error message and event notification should be sent immediately.
| setTimeout(() => { | |
| this.sendingFeedback = false; | |
| this.sendMessage({ | |
| name: "feedback-sending-failed", | |
| data: "Something went wrong, please try again.", | |
| }); | |
| GleapEventManager.notifyEvent("error-while-sending"); | |
| this.sendMessage({ | |
| name: "feedback-sending-failed", | |
| data: "Something went wrong, please try again.", | |
| }); | |
| GleapEventManager.notifyEvent("error-while-sending"); | |
| setTimeout(() => { | |
| this.sendingFeedback = false; |
| setTimeout(() => { | ||
| this.sendingFeedback = false; | ||
| }, 1000); |
There was a problem hiding this comment.
The debounce delay of 1000ms is hardcoded in multiple places. Consider extracting this as a named constant (e.g., FEEDBACK_DEBOUNCE_DELAY = 1000) at the class level to improve maintainability and make it easier to adjust if needed.
No description provided.