Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 15828 - Notification comment support in the new comment editor #15884

Conversation

RenanLukas
Copy link
Contributor

@RenanLukas RenanLukas commented Feb 1, 2022

Fixes #15828

Currently only Site Comments are supported in the new comment editor. The goal of this PR is to also allow Notification Comments to be shown and editable in the new comment editor (instead of the legacy editor). It also tries to make it easier to support other Comment types in the future (e.g. Reader).

Screen Shot 2022-02-03 at 2 43 47 PM Screen Shot 2022-02-03 at 2 43 52 PM

Screen Shot 2022-02-03 at 2 43 59 PM Screen Shot 2022-02-03 at 2 44 02 PM

To test:
1 - Login with an user that has at least one notification of a comment;
2 - Select any site;
3 - Tap on "Notifications" bottom navigation icon to open Notifications screen;
4 - Tap on "Comments" tab inside Notifications screen;
5 - Tap on the comment you want to test;
6 - Tap on "More" button;
7 - Tap on "Edit" item. The notification comment edit should be opened in the new comment editor;
8 - Edit the comment text;
9 - Tap on "Done";
10 - The comment text should be updated.

Regression Notes

  1. Potential unintended areas of impact
    None

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

  1. What automated tests I added (or what prevented me from doing so)
  • CommentEssentialsTest.kt
  • CommentSourceTest.kt
  • CommentEssentialsExtensionKtTest.kt
  • GetCommentUseCaseTest.kt
  • Included more tests in UnifiedCommentsEditViewModelTest.kt

PR submission checklist:

  • I have completed the Regression Notes.
  • 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.

@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Feb 1, 2022

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Feb 1, 2022

You can test the changes on this Pull Request by downloading the APKs:

@RenanLukas RenanLukas marked this pull request as ready for review February 3, 2022 04:52
@RenanLukas RenanLukas changed the title [WIP] Issue 15828 - Notification comment support in the new editor Issue 15828 - Notification comment support in the new editor Feb 3, 2022
Copy link
Member

@khaykov khaykov left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @RenanLukas ! Looks good and works well :) I left couple of small nitpicks in the code :)

As we discussed, let's keep this PR unmerged, until we can update the content of the comment in notification details (not list) after the edit.

} ?: showUpdateCommentError()
}

private suspend fun updateCommentEntityLocalDatabase(
Copy link
Member

Choose a reason for hiding this comment

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

About the method name - updateEditComment pushes the comment to sever as well, but I don't think that VM needs to know about what is happening there :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thank you! I had this decision in the VM before extracting it to the UseCase and completely missed this name 😅
Changing it

@@ -80,7 +80,7 @@ public void onErrorResponse(VolleyError error) {
}
}

public static void downloadNoteAndUpdateDB(final String noteID, final RestRequest.Listener respoListener,
public static void downloadNoteAndUpdateDB(final String noteID, final RestRequest.Listener requestListener,
Copy link
Member

Choose a reason for hiding this comment

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

Good catch 👍

whenever(commentsStore.getCommentByLocalSiteAndRemoteId(siteModel.id, remoteCommentId))
.thenReturn(emptyList())
whenever(commentsStore.fetchComment(siteModel, remoteCommentId, null))
.thenReturn(CommentsActionPayload(CommentsActionData(emptyList(), 1)))
Copy link
Member

Choose a reason for hiding this comment

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

NP: Doesn't affect the test, but the rowsAffected in CommentsActionData will probably be 0 in this case :)

}

@Test
fun `Should map CommentIdentifier to default CommentEssentials if CommentIdentifier comment not found`() {
Copy link
Member

Choose a reason for hiding this comment

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

NP: Wonder if this method signature should have = test {...} instead of { test{...} }

}

@Test
fun `Should map CommentIdentifier to default CommentEssentials if CommentIdentifier not handled`() {
Copy link
Member

Choose a reason for hiding this comment

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

Do we want the test to use runBlocking (= test{...}) or is it ok like this?

@RenanLukas
Copy link
Contributor Author

Thank you for the review @khaykov 🎉 I've addressed the comments.

As we discussed, let's keep this PR unmerged, until we can update the content of the comment in notification details (not list) after the edit.

Deal 👍 I'm on it

@RenanLukas
Copy link
Contributor Author

This PR depends on #15918

RenanLukas and others added 3 commits February 11, 2022 10:08
…ication-comment-details-content-not-updated-after-editing

Issue 15910 - Fix notification comment details content not updated after editing
Copy link
Member

@khaykov khaykov left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the issues from the review, and fixing the issue with notification content not updating. Now everything works as expected :)

@khaykov khaykov merged commit 2133ad3 into trunk Feb 11, 2022
@khaykov khaykov deleted the issue/15828-migrate-edited-comment-notification-logic-to-new-editor branch February 11, 2022 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move legacy edited comment notification logic to the new comment editor.
2 participants