Show a toast after successfully submitting a comment. - #25945
Show a toast after successfully submitting a comment.#25945Vivek09Chahal wants to merge 9 commits into
Conversation
|
Currently only implemented Toast message show up, as we don't have access to the unapproved comments. So can't implement
this for now as comment API only send the data of the approved comments. |
| iconColor: UIAppColor.success, title: Strings.commentHeldForModeration | ||
| )) | ||
| .post() | ||
| } |
There was a problem hiding this comment.
This notice does not apply to all sites, right? Some site you can just publish without being reviewed. Like, if you are member of another site, your comments on that site should go straight to approved?
There was a problem hiding this comment.
ok will update according to that 🤔
There was a problem hiding this comment.
Updated Code, now toast will show only when comment is unapproved.
The core problem: the composer had no way to know whether a comment was actually held for moderation. I traced the real status through the whole call chain and made it flow back to the UI.
| /// - title: When provided (with or without `icon`), builds `attributedMessage` from it and makes the | ||
| /// Notice auto-dismiss after a few seconds. When `nil`, the Notice falls back to its own `title`/`message` | ||
| /// and stays on screen until the user dismisses it, matching the original in-app-update banner behavior. | ||
| init(icon: UIImage? = nil, iconColor: UIColor = .invertedLabel, title: String? = nil) { |
There was a problem hiding this comment.
Any reason for adding this new initializer? Does the default Notice work?
There was a problem hiding this comment.
init already existed for this struct it just got updated, to reuse the existing notification item, to reuse it I have to add 2 new value in here
- Image: UIImage
- Image Color: UIColor
And before we were only accepting NSAttributedString changed to String it will accept string now instead of NSAttributedString and it was already optional.
Before it didn't have support of the image. Now it do, Both Optional, as if we want to use old style, we no need to pass down those value and it will set back to previous version
There was a problem hiding this comment.
Just on clarification, before this Notice was not dismissible, it stays on the screen until user removed it, its value was set to false, now it can get auto-dismiss after few seconds.
I can revert this just one line change, if there is no need.
Please clarify on this one.
| func save(content: String) async throws { | ||
| try await _save(content) | ||
| /// - returns: `true` if the comment is pending moderation (not immediately approved). | ||
| func save(content: String) async throws -> Bool { |
There was a problem hiding this comment.
It's not obvious what this boolean return value (and a few other updated functions) means. Can we tweak this? Like, maybe returning the TaggedManagedObjectID<Comment>, and the view controller can decide what to do with it?
There was a problem hiding this comment.
Updated the pass down value to TaggedManagedObjectID
now checking the condition when buttonSendTapped() is called instead of sending the Bool value directly.
guard let comment = try? ContextManager.shared.mainContext.existingObject(with: commentID), !comment.isApproved() else { return }
…n-on-comment-submit
…b.com/Vivek09Chahal/WordPress-iOS into Toast-Implemetation-on-comment-submit
…n-on-comment-submit
Description
Open issue: #24573
When a user submits a comment (or a reply) on a post, the composer previously just dismissed with no feedback. This adds a toast/notice confirming the submission, shown only when the comment is held for moderation (i.e. not auto-approved), so the user understands why their comment isn't visible yet.
Changes
The core problem: the composer had no way to know whether a comment was actually held for moderation. I traced the real status through the whole call chain and made it flow back to the UI.
CommentService(replyToPost:/replyToHierarchicalCommentWithID:) — thesuccessblock now passes back the createdComment(void (^)(Comment * _Nullable)) so callers can inspect its approval status. The reply object is re-fetched from the main context viaexistingObjectWithID:error:.CommentCreateViewModel—save(content:)and the internal_save/sendCommentclosures now returnBool("is pending moderation"), derived fromnewComment?.isApproved() == false.CommentCreateViewController— after a successful save, once the composer is dismissed it posts aNoticewithInAppUpdateNoticeStylewhenisPendingModerationistrue. Copy: "Comment is awaiting review" (new localized stringcommentCreate.commentHeldForModeration).CommentDetailViewController—createReply/createPostCommentReplyupdated to propagate the sameBoolthrough to the composer.InAppUpdateNoticeStyle— extended with a new initializer taking an optional SF Symbolicon,iconColor, andtitle:titleis given → builds anattributedMessage(icon inline before bold text) and makes the notice auto-dismiss.nil→ keeps the original persistent in-app-update banner behavior.isDismissableis now set per-instance instead of a hardcodedfalse.checkmark.seal.filltintedUIAppColor.success.Testing instructions
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-08-26.at.18.18.44.mov