Repository navigation
Fix #19: allow changing and retracting feedback votes - #31
Open
xiaoyao-666-coder wants to merge 2 commits into
Open
xiaoyao-666-coder wants to merge 2 commits into
xiaoyao-666-coder wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
投过票后无法改票/撤销:
sendFeedback开头if (feedbackSent[messageId]) return,投过一次后点另一个按钮直接 return,不发请求、不报错、无提示,用户以为按钮坏了。修复
后端本来就支持改票(
add_feedback按session:messageupsert),堵在前端:feedbackPending的防重复点击。点另一项时照常 POST/api/feedback,成功后更新feedbackSent;失败时 toast 提示且本地状态不动(状态只在成功响应后才更新,无需回滚)。投票逻辑抽成纯模块frontend/src/feedback-vote.ts,按钮补了aria-pressed和动态 title。DELETE /api/feedback(与 POST 同样的鉴权、会话归属 404 与response_ids422 校验;幂等,第二次返回changed:false)。MetricsStore.remove_feedback(内存版)与新增_REMOVE_FEEDBACK_SCRIPTLua(Redis,原子 HDEL + 计数 −1)。撤销只删 rating,commented计数不动(那是 [高] 反馈 comment 文本被接受后直接丢弃,保存了也无处可查 #21 的范围)。验证
MEDGUIDE_MODE=test python -m pytest -q backend/tests529 passed(基线 521 + 8 新)。覆盖:改票 up→down 计数正确搬移、重复同分提交changed:false、撤销后计数归零且二次撤销changed:false、无票撤销不改变计数、撤销后可重新投票、撤销未知会话 404 / 非本会话消息 422 / 缺参数 422、Redis 64 并发撤销仅 1 次changed:true且计数归零。npm test15 pass、0 fail(基线 10 + 5 新),npm run build正常。.selected样式切换需在真机/浏览器上点一次确认。已知遗留
刷新页面后
feedbackSent是纯内存 state,会丢失——用户刷新后看到的仍是未投票状态。这是 #19 之外的既有行为(后端没有读回单条回答投票状态的接口),如需持久化投票状态展示,需另开 issue。Closes #19