fix(通知信箱): 加载优化与全部已读提示(#641/#665) - #1001
Conversation
通知卡片标题与按钮 flex 行默认 align-items:stretch,标题多行时按钮被拉伸。 改为 align-items:flex-start,使按钮保持自身高度并顶部对齐。 Files changed: - templates/notifications.html
- notification2Display 中 select_related("sender") 的返回值此前未赋回变量,
导致后续循环逐条查询 sender,产生 N+1 查询;现改为赋值回 notifications。
- notifications 视图 readall 分支在已读数为 0 时仍弹出成功提示,
改为仅当 count>0 时才 succeed,避免空操作误报成功。
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 046d45c7d0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| notificaiton_set.update( | ||
| status=Notification.Status.DONE, finish_time=datetime.now()) | ||
| succeed(f"成功将{count}条通知设为已读!", html_display) | ||
| if count: |
There was a problem hiding this comment.
Move “read all” behind a CSRF-protected POST
This modified branch is still invoked by GET /notifications/?read_name=readall, so a cross-site top-level navigation or request prefetch carrying the user's session can mark every unread NEEDREAD notification as done. Move the action to a POST endpoint, apply csrf_protect, and have the menu submit a CSRF token; the repository explicitly requires adding these protections when modifying an existing session-authenticated mutation.
AGENTS.md reference: AGENTS.md:L498-L504
Useful? React with 👍 / 👎.
| notificaiton_set.update( | ||
| status=Notification.Status.DONE, finish_time=datetime.now()) | ||
| succeed(f"成功将{count}条通知设为已读!", html_display) | ||
| if count: |
There was a problem hiding this comment.
Base the success condition on the update row count
If a matching notification is created after count() returns zero but before update() executes, the update marks that newly delivered notification as done while this condition remains false, so the user never sees either the notification or feedback that it was consumed. Use the affected-row count returned by QuerySet.update() for both the condition and message, or otherwise serialize the read and write.
AGENTS.md reference: AGENTS.md:L429-L437
Useful? React with 👍 / 👎.
优化通知信箱加载逻辑,修复多行标题时按钮被拉长的问题。基于 upstream/develop 重建。