Skip to content

Conversation

@kean
Copy link
Contributor

@kean kean commented Feb 19, 2025

This PR adds support for editing existing comments from Reader, including Gutenberg comments.

Instead of a single CommentComposerViewController, I created separate classes to make sure it's easy to follow what's going on. There were too many small differences to keep it in a single file.

  • CommentCreateViewController, CommentCreateViewModel for creating new comments
  • CommentEditViewController, CommentEditViewModel for editing existing comments
  • CommentEditorViewController for hiding the complexity of dealing with plain text and Gutenberg comments

Related PR: wordpress-mobile/WordPressKit-iOS#830

Changes

  • Add support for editing comments using the new CommentEditViewController (recording: plain text, blocks)

Fixes

  • Fix an issue where draft wasn’t discarded after successfully sending a comment (recording)
  • Fix an issue with composer not using the latest text from Gutenberg – text is now an async property

Known Issues

  • When you create or edit a Gutenberg comment, the server removes some of the required tags – investigating
  • You can edit only comments that you can also moderate. You can't edit your own comments on public sites (production behavior)

Testing

Note: enable "Gutenberg Comment Composer" for testing

  • Smoke test the comment composer
  • Verify the fixes
  • Verify that you can edit comments on P2s
  • Verify that "Save" button becomes enabled only when you make changes
  • Verify that "Cancel" button shows a confirmation dialog when there are changes and you can't dismiss the screen interactively if there are changes

Regression Notes

  1. Potential unintended areas of impact

  2. What I did to test those areas of impact (or what existing automated tests I relied on)

  3. What automated tests I added (or what prevented me from doing so)

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Testing checklist:

  • WordPress.com sites and self-hosted Jetpack sites.
  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • VoiceOver.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • iPhone and iPad.
  • Multi-tasking: Split view and Slide over. (iPad)

@kean kean added the Comments label Feb 19, 2025
@kean kean added this to the 25.8 milestone Feb 19, 2025
@dangermattic
Copy link
Collaborator

dangermattic commented Feb 19, 2025

3 Warnings
⚠️ Modules/Package.swift was changed without updating its corresponding Package.resolved. Please resolve the Swift packages as appropriate to your project setup (e.g. in Xcode or by running swift package resolve).
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ This PR is assigned to the milestone 25.8. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by 🚫 Danger

@kean kean force-pushed the task/enable-gutenberg-comment-editor branch from 46e049b to f129705 Compare February 19, 2025 22:56
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Feb 19, 2025

WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr24093-db430bb
Version25.7.1
Bundle IDorg.wordpress.alpha
Commitdb430bb
App Center BuildWPiOS - One-Offs #11528
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Feb 19, 2025

Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr24093-db430bb
Version25.7.1
Bundle IDcom.jetpack.alpha
Commitdb430bb
App Center Buildjetpack-installable-builds #10560
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@kean kean force-pushed the task/enable-gutenberg-comment-editor branch from f129705 to dceffdf Compare February 20, 2025 14:00
@kean kean changed the title Add support for editing comments using CommentComposerViewController Add support for editing comments Feb 20, 2025
@kean kean marked this pull request as ready for review February 20, 2025 16:17
@kean kean requested a review from crazytonyli February 20, 2025 16:17
let commentID = comment.commentID as NSNumber
let service = CommentService(coreDataStack: ContextManager.shared)

let remoteComment = try await withUnsafeThrowingContinuation { continuation in
Copy link
Contributor

Choose a reason for hiding this comment

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

What are the benefits of using withUnsafeThrowingContinuation vs withCheckedThrowingContinuation in this context?

Copy link
Contributor Author

@kean kean Feb 20, 2025

Choose a reason for hiding this comment

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

I don't think I've used withCheckedThrowingContinuation before because AFAIU it throws a fatalError if there you don't adhere to one of its rules.

Copy link
Contributor

Choose a reason for hiding this comment

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

On that aspect, I guess the "checked" version fails early, but who knows what it means if we are not "being extra careful".

Unlike the “checked” continuation variant, the UnsafeContinuation does not detect or diagnose any kind of misuse, so you need to be extra careful to avoid calling resume twice or forgetting to call resume before letting go of the continuation object.

@kean kean added this pull request to the merge queue Feb 21, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Feb 21, 2025
@kean kean added this pull request to the merge queue Feb 21, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Feb 21, 2025
@kean kean added this pull request to the merge queue Feb 21, 2025
Merged via the queue into trunk with commit 07afa21 Feb 22, 2025
25 checks passed
@kean kean deleted the task/enable-gutenberg-comment-editor branch February 22, 2025 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants