Skip to content

Show a toast after successfully submitting a comment. - #25945

Open
Vivek09Chahal wants to merge 9 commits into
wordpress-mobile:trunkfrom
Vivek09Chahal:Toast-Implemetation-on-comment-submit
Open

Show a toast after successfully submitting a comment.#25945
Vivek09Chahal wants to merge 9 commits into
wordpress-mobile:trunkfrom
Vivek09Chahal:Toast-Implemetation-on-comment-submit

Conversation

@Vivek09Chahal

@Vivek09Chahal Vivek09Chahal commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

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:) — the success block now passes back the created Comment (void (^)(Comment * _Nullable)) so callers can inspect its approval status. The reply object is re-fetched from the main context via existingObjectWithID:error:.
  • CommentCreateViewModelsave(content:) and the internal _save / sendComment closures now return Bool ("is pending moderation"), derived from newComment?.isApproved() == false.
  • CommentCreateViewController — after a successful save, once the composer is dismissed it posts a Notice with InAppUpdateNoticeStyle when isPendingModeration is true. Copy: "Comment is awaiting review" (new localized string commentCreate.commentHeldForModeration).
  • CommentDetailViewControllercreateReply / createPostCommentReply updated to propagate the same Bool through to the composer.
  • InAppUpdateNoticeStyle — extended with a new initializer taking an optional SF Symbol icon, iconColor, and title:
    • When a title is given → builds an attributedMessage (icon inline before bold text) and makes the notice auto-dismiss.
    • When nil → keeps the original persistent in-app-update banner behavior.
    • isDismissable is now set per-instance instead of a hardcoded false.
    • The toast uses checkmark.seal.fill tinted UIAppColor.success.

Testing instructions

  1. Sign in and open a post in the Reader whose site holds comments for moderation (or comment as a non-member on a site that moderates first-time commenters).
  2. Tap the comment field, type a comment, and send.
  3. Verify the composer dismisses and a toast appears: "Comment is awaiting review" with a green checkmark-seal icon, auto-dismissing after a few seconds.
  4. Repeat for a reply to an existing comment, from both the Reader comments thread and a comment opened via Notifications.
  5. On a site where your comments are auto-approved, verify no toast appears (comment just posts).
  6. Check: light/dark mode, larger Dynamic Type, VoiceOver (icon is decorative, title is read), RTL layout.
  7. Regression-check the existing in-app-update banner (persistent, non-dismissable) still looks and behaves as before.
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-08-26.at.18.18.44.mov

Copilot AI lite review requested due to automatic review settings August 26, 2026 14:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Vivek09Chahal

Copy link
Copy Markdown
Contributor Author

Currently only implemented Toast message show up, as we don't have access to the unapproved comments. So can't implement

We display the pending comment in the comments list with a special "awaiting review" status to communicate that the comment successfully posted, but is not yet publicly visible.

this for now as comment API only send the data of the approved comments.

iconColor: UIAppColor.success, title: Strings.commentHeldForModeration
))
.post()
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok will update according to that 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for adding this new initializer? Does the default Notice work?

@Vivek09Chahal Vivek09Chahal Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Image: UIImage
  2. 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

@Vivek09Chahal Vivek09Chahal Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@Vivek09Chahal Vivek09Chahal Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants