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

Determine new notifications in extension and display #4046

Merged
merged 16 commits into from Nov 16, 2021
Merged

Conversation

tonisevener
Copy link
Collaborator

@tonisevener tonisevener commented Oct 1, 2021

Phabricator:
https://phabricator.wikimedia.org/T288773
https://phabricator.wikimedia.org/T285353
& Some of https://phabricator.wikimedia.org/T287033

Notes

This extends the work done in #4026 to pull the latest unread push notifications from the notifications API, filters out previously seen notifications via an app container cache file and displays the results. If the result is a single new unread notification, it modifies the push content to display it's header value. There is also some extra handling for talk page notification types (adds subtitle, bundles if necessary) based on the Figma mocks. For all other situations, it defaults to "New activity on Wikipedia" text.

After review, please wait for #4044 to be reviewed and merged. Then update this with feature/notifications and merge into that feature branch.

These steps should be tested through the Beta Cluster via the Staging scheme.

Test Steps

  1. Fresh install from this branch and log in from an account that has all checkboxes checked on desktop Wikipedia notifications preferences. Go to Settings > Notifications and enable notifications.
  2. Do something to trigger a notification to yourself from another account on desktop Wikipedia. I tend to test by thanking an edit, undoing an edit, or writing on my talk page with another account.
  3. Wait for notifications to appear on your phone. On Staging scheme / beta cluster desktop it takes about 10 seconds for me lately.
  4. The first notification will likely say "New activity on Wikipedia", since all notifications appear new to the device, and it sees it as condensing multiple notification types.
  5. Trigger another notification (thanks or undo edit).
  6. Now you should see a push with content specific push notification content.
  7. Go to your user talk page and write on it.
  8. Now you should see a push with content specific push notification content, plus a "New message" subtitle.
  9. Get a couple of browser tabs open with editing your talk page. Try to post two updates back to back to trigger a batched talk page notification
  10. Now you should see a push with batched content, "N new messages on {Title}", as well a "New messages" subtitle.
  11. Go to desktop notifications preferences, uncheck "Thanks" from the app column.
  12. Trigger a thanks again to yourself. Confirm no notification appears on your device.

@tonisevener tonisevener added the Dependent PR PR is dependent on another PR - merge dependent PR first and update branch before merging label Oct 1, 2021
@tonisevener tonisevener requested review from a team and staykids and removed request for a team October 1, 2021 19:01
@tonisevener tonisevener force-pushed the T288662-data-connection branch 2 times, most recently from 285bea6 to 9924f8d Compare October 5, 2021 20:12
@staykids
Copy link
Contributor

@tonisevener Just a head's up – merge conflict in this one (surrounding the prefixed localized string changes in #4044).

@tonisevener
Copy link
Collaborator Author

Just a head's up – merge conflict in this one (surrounding the prefixed localized string changes in #4044).

@staykids Thanks, this should be fixed now.

Base automatically changed from T288662-data-connection to feature/notifications October 18, 2021 23:24
@tonisevener tonisevener removed the Dependent PR PR is dependent on another PR - merge dependent PR first and update branch before merging label Oct 19, 2021
@staykids
Copy link
Contributor

@tonisevener Looks like a few more merge conflicts have snuck into this one.

@mcleinman
Copy link
Contributor

Snagging this PR from you, @staykids

@tonisevener tonisevener changed the base branch from feature/notifications to main November 9, 2021 20:58
Copy link
Contributor

@mcleinman mcleinman left a comment

Choose a reason for hiding this comment

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

This looks great! Just a bunch of small suggested tweaks.

WMF Framework/SharedContainerCache.swift Outdated Show resolved Hide resolved
Wikipedia/Code/WMFAppViewController.m Outdated Show resolved Hide resolved
NotificationServiceExtension/NotificationService.swift Outdated Show resolved Hide resolved
NotificationServiceExtension/NotificationService.swift Outdated Show resolved Hide resolved
NotificationServiceExtension/NotificationService.swift Outdated Show resolved Hide resolved
NotificationServiceExtension/NotificationService.swift Outdated Show resolved Hide resolved
NotificationServiceExtension/NotificationService.swift Outdated Show resolved Hide resolved
NotificationServiceExtension/NotificationService.swift Outdated Show resolved Hide resolved
@tonisevener tonisevener self-assigned this Nov 10, 2021
- Clean up and refactor business logic out of NotificationService and move into separate helper class
- Add ability to generate mock notifications, write unit tests against new helper class
- Add Remote Notifications directory to localization script so that new helper class strings are localized.
- Small naming and comment tweaks
- Even with one talk page notification, we still need "New message" subtitle according to designs.
@tonisevener
Copy link
Collaborator Author

@mcleinman This is ready for another look. I went through the test steps and had to push one little bug fix commit after the refactor. I didn't receive push notifications through the beta cluster though, so I leaned on the push utility. It could be that backend is stalling or not working at the moment, or I just wasn't patient enough.

Copy link
Contributor

@mcleinman mcleinman left a comment

Choose a reason for hiding this comment

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

Just a couple small ones - one I think helps readability, others are nice to have.

@mcleinman
Copy link
Contributor

Code looks great, will be testing this tomorrow.

Copy link
Contributor

@mcleinman mcleinman left a comment

Choose a reason for hiding this comment

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

Code looks great, and tests great! Thank you!

@mcleinman mcleinman merged commit 33cae1e into main Nov 16, 2021
@mcleinman mcleinman deleted the T287310-2 branch November 16, 2021 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants