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

[Notifications Refresh] Present Comment Moderations Options View #23175

Conversation

salimbraksa
Copy link
Contributor

@salimbraksa salimbraksa commented May 8, 2024

Fixes https://github.com/Automattic/wordpress-mobile/issues/38

Description

This pull request adds logic where tapping the 'Change Status' button in the header menu brings up the Comment Moderation Options view.

iPhone iPad

Test Instructions

  1. Run Jetpack and login.
  2. Navigate to "Notifications" screen.
  3. Select a "Comment" notification.
  4. Tap the more menu.
  5. Tap "Change Status" button.
  6. Expect the Comment Moderation Options sheet to appear.
  7. Select any option.
    • The status is updated but I didn't bother to update the outdated comment status moderation view since it will be removed.
  8. Go back to the previous screen.
  9. Tap the same comment notification.
  10. Verify the outdated comment moderation UI is updated.

Regression Notes

  1. Potential unintended areas of impact
    N/A

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

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

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)

@salimbraksa salimbraksa changed the base branch from trunk to feature/notifications_refresh_p2 May 8, 2024 17:23
@salimbraksa salimbraksa self-assigned this May 8, 2024
@salimbraksa salimbraksa added this to the Pending milestone May 8, 2024
@wpmobilebot
Copy link
Contributor

wpmobilebot commented May 8, 2024

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 Numberpr23175-346b52c
Version24.8
Bundle IDorg.wordpress.alpha
Commit346b52c
App Center BuildWPiOS - One-Offs #9845
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

import SwiftUI
import WordPressUI

class BottomSheetContentViewController: UIViewController {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This logic was extracted from CompliancePopoverViewController. I was going to implement the same class for the Comment Moderations Options View but then I thought why not implement a reusable component instead.

I'll open a separate PR to refactor the CompliancePopoverViewController to use this class.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented May 8, 2024

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 Numberpr23175-346b52c
Version24.8
Bundle IDcom.jetpack.alpha
Commit346b52c
App Center Buildjetpack-installable-builds #8893
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

if let presentationController = parent?.presentationController as? DrawerPresentationController {
presentationController.transition(to: presentationController.currentPosition)
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code adjusts the layout of the bottom sheet when fonts are enlarged. I needed a way to update the parent view in response to changes in the child view's size. While I don't like this approach of accessing DrawerPresentationController due to it making too many assumptions about implementation details, it is the best approach I could think of.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to handle the else path here? I think it is fine as long as it works with other VC types. Otherwise, it would make sense to specify the type rather than make it look like it is more flexible.

@salimbraksa salimbraksa marked this pull request as ready for review May 8, 2024 18:01
@@ -140,6 +140,10 @@ class CommentDetailViewController: UIViewController, NoResultsViewHost {
return cell
}()

private weak var changeStatusViewController: UIViewController?
Copy link
Contributor

Choose a reason for hiding this comment

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

If that's the presenting view controller, you can use unowned here and maybe specify the VCType rather than using UIViewController since the name already specifies it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's the bottom sheet view controller being presented. I need to keep a reference to this view controller so I can dismiss it later when the user selects a status. The reference is optional because the view controller might not always be present.

While now it's possible to have optional unowned references:

private unowned var changeStatusViewController: BottomSheetViewController?

Unlike with weak, the reference won't automatically turn nil if the object is deallocated. Accessing a deallocated object will cause the app to crash.

I need the object to automatically turn nil when the view controller is deallocated ( aka dismissed ).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe specify the VCType rather than using UIViewController since the name already specifies it.

Resolved in 346b52c

if let presentationController = parent?.presentationController as? DrawerPresentationController {
presentationController.transition(to: presentationController.currentPosition)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to handle the else path here? I think it is fine as long as it works with other VC types. Otherwise, it would make sense to specify the type rather than make it look like it is more flexible.

Copy link
Contributor

@alpavanoglu alpavanoglu left a comment

Choose a reason for hiding this comment

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

AC is satisfied. All actions work as expected.

@salimbraksa salimbraksa force-pushed the task/comment_moderation_change_status_ui branch from b59804a to 346b52c Compare May 9, 2024 10:19
@salimbraksa salimbraksa merged commit 4a4fc79 into feature/notifications_refresh_p2 May 9, 2024
25 of 29 checks passed
@salimbraksa salimbraksa deleted the task/comment_moderation_change_status_ui branch May 9, 2024 11:46
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.

None yet

3 participants