-
Notifications
You must be signed in to change notification settings - Fork 305
notif: Ignore notifications for logged out accounts #1349
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
base: main
Are you sure you want to change the base?
Conversation
Thanks @tomlin7 for the contribution! Before we can review this, it will need a test — see the repo's README file. |
6c31bb2
to
51c72de
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Comments below from a brief review.
90daa5f
to
bbd7f14
Compare
I believe the two questions above that were open now have answers:
So you should be able to proceed, incorporating those. |
610d6d7
to
004951d
Compare
@chrisbobbe I have made the requested changes, please review again! |
Quoting my comment #1349 (comment):
You haven't done this in this revision; please do that. In
I see some added asserts, but this needs to be done in a separate commit. The current revision only has one commit. |
aba2741
to
1405cc1
Compare
@chrisbobbe I have implemented all the requested changes. Let me know if there are any further improvements needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Comments below.
Also, have you tested this with an Android device or emulator?
b49b478
to
b88bb4d
Compare
@chrisbobbe I have tested this with an Android device (both debug and release). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! A few comments from a brief review—also, some tests are failing; please fix those.
b88bb4d
to
27bcdc2
Compare
The `_groupKey` method currently takes an `FcmMessageWithIdentity` object as an argument. However, this method only requires the realm URL and user ID from that object. This change modifies the method signature to directly accept `realmUrl` and `userId` as arguments. This change is made to facilitate calling `_groupKey` from contexts where an `FcmMessageWithIdentity` object is not available. Discussion: https://chat.zulip.org/#narrow/channel/516-mobile-dev-help/topic/Removing.20notifications.20for.20logged.20out.20account/near/2088813
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @tomlin7 for building this, and @chrisbobbe for the previous reviews!
The implementation looks correct to me; just small comments below. There's a few more things I'd like to see in the tests.
@rajveermalviya, would you take a look at this and
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested the following cases and verified they work correctly:
- The notifications being removed when logging-out of the account.
- Receiving a notification from FCM but not displaying it when the account wasn't found in GlobalStore (simulating that the API call to
unregisterToken
failed, by commenting it out).
Also since this PR removes the notification by matching groupKey
, it should also include the group summary notification and remove it, avoiding a lingering summary notification.
As for the interaction with #1379, apart from little conflicts, there shouldn't be anything that requires changing here, as this PR only checks for the notification group key (to find and remove notifications of the specific account) and there's no change in regarding to that in #1379. And for iOS this shouldn't matter for now (but remains unresolved), as we don't have a way to control displaying notifications there yet (#1265), and also because #1264 is only about Android.
Thanks @rajveermalviya! Sounds good. |
e2cf339
to
4dafcb9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the revision! These tests look complete now. Comments below.
1d43bd8
to
ad49b0b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the revision! This is very close now. Comments below.
Some of these comments are additional cases of things that I mentioned in the previous review. When you get code-review feedback on a PR, one key thing you can do to help keep the PR moving swiftly along to merge is to look for other places where the same comments would apply, and act on the feedback in those places too.
Fixes: zulip#1264 Notifications are ignored for accounts which were logged out but the request to stop receiving notifications failed due to some reason. Also when an account is logged out, any existing notifications for that account is removed from the UI.
…ethods NotificationDisplayManager's public methods only get invoked on Android, and their implementations basically assume the platform is Android. So, add these asserts, to make that assumption clearer and to fail early if we accidentally call one of these on iOS. When we eventually take more hands-on control of notifications on iOS, we might either adapt this class to support iOS too, or make a new class for iOS and make this one's name and interface clearer that it's Android-only. Discussion: https://chat.zulip.org/#narrow/channel/243-mobile-team/topic/NotificationDisplayManager.20Android-only/near/2099196
ad49b0b
to
5f52b54
Compare
Thanks for the suggestions! It's improving my code quality significiantly. I made sure to run the suggestions through all changes made. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the revision! Just a few nits remain.
final message = eg.dmMessage(from: eg.otherUser, to: [eg.selfUser]); | ||
|
||
receiveFcmMessage(async, messageFcmMessage(message)); | ||
check(testBinding.androidNotificationHost.activeNotifications).isNotEmpty(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: these are closely tied, so group together in one stanza:
final message = eg.dmMessage(from: eg.otherUser, to: [eg.selfUser]); | |
receiveFcmMessage(async, messageFcmMessage(message)); | |
check(testBinding.androidNotificationHost.activeNotifications).isNotEmpty(); | |
final message = eg.dmMessage(from: eg.otherUser, to: [eg.selfUser]); | |
receiveFcmMessage(async, messageFcmMessage(message)); | |
check(testBinding.androidNotificationHost.activeNotifications).isNotEmpty(); |
(e.g., that message
local exists only to be used on that next line, so those two lines belong in the same stanza)
id: 1001, user: eg.user(userId: userId), realmUrl: Uri.parse('https://realm1.example')); | ||
final account2 = eg.account( | ||
id: 1002, user: eg.user(userId: userId), realmUrl: Uri.parse('https://realm2.example')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the key info here (the parts of the realm URLs that differ) is still past 80 columns
await NotificationDisplayManager.removeNotificationsForAccount(realmUrl, account1.userId); | ||
check(testBinding.androidNotificationHost.activeNotifications) | ||
..length.equals(2) | ||
..first.notification.group.equals('$realmUrl|${account2.userId}'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
await NotificationDisplayManager.removeNotificationsForAccount(realmUrl, account1.userId); | |
check(testBinding.androidNotificationHost.activeNotifications) | |
..length.equals(2) | |
..first.notification.group.equals('$realmUrl|${account2.userId}'); | |
await NotificationDisplayManager.removeNotificationsForAccount( | |
realmUrl, account1.userId); | |
check(testBinding.androidNotificationHost.activeNotifications) | |
..length.equals(2) | |
..first.notification.group.equals('$realmUrl|${account2.userId}'); |
otherwise "account1.userId
" is hidden off past 80 columns, and that's the key information for interpreting the check at the end of the test
Fixes: #1264
Changes