fix: keep comment editor open on save failure

This commit is contained in:
Tienson Qin
2026-05-25 20:09:51 +08:00
parent ef7730a851
commit a4e423c6eb
3 changed files with 8 additions and 2 deletions

View File

@@ -9,6 +9,7 @@
[frontend.date :as date]
[frontend.format.block :as block]
[frontend.handler.comments :as comments-handler]
[frontend.handler.notification :as notification]
[frontend.handler.paste :as paste-handler]
[frontend.handler.reaction :as reaction-handler]
[frontend.handler.user :as user-handler]
@@ -337,8 +338,11 @@
:refocus-after-submit? false
:on-cancel #(set-editing! false)
:on-submit (fn [content]
(comments-handler/save-comment! comment-block content)
(set-editing! false))})
(-> (comments-handler/save-comment! comment-block content)
(p/then (fn [_]
(set-editing! false)))
(p/catch (fn [_error]
(notification/show! (t :block.comments/save-error) :error)))))})
[:div.ls-comment-body
(block-content-or-editor
config

View File

@@ -117,6 +117,7 @@
:block.comments/label "Comments"
:block.comments/on-those-blocks "On those blocks"
:block.comments/placeholder "Reply..."
:block.comments/save-error "Failed to save comment."
:block.comments/yesterday-at "Yesterday at {1}"
:block.macro/embed-deprecated "{{embed}} is deprecated. Use '/Node embed' command instead."

View File

@@ -114,6 +114,7 @@
:block.comments/label "评论"
:block.comments/on-those-blocks "在这些块上"
:block.comments/placeholder "回复..."
:block.comments/save-error "保存评论失败。"
:block.comments/yesterday-at "昨天 {1}"
:block.macro/embed-deprecated "{{embed}} 已弃用。请改用“/节点嵌入”命令。"