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: simplify the flow by removing persistence #2924

Merged
merged 16 commits into from
May 29, 2024

Conversation

jmartinesp
Copy link
Member

@jmartinesp jmartinesp commented May 27, 2024

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

  • Remove persistence layer for notifications, which should make the flow a lot simpler.
  • Bump of minSdk to 24, since it's needed to be able to reuse MessagingStyle notifications and get rid of the persistence.

Motivation and context

Having this persistence layer was needed for APIs 21-23, but it means having to handle a lot more logic than needed and ended up causing issues as #609 and probably #790.

While we could spend time trying to fix those issues, it's probably better to just drop support for persistence since the number of users in those Android versions are quite low and once we've bumped the minSdk there's no need to keep supporting our custom persistence layer anymore.

Tests

  • Test opening and dismissing notifications.
  • Check notifications for room messages are removed when you visit the room.
  • Check summary one gets removed when you dismiss the last message/invite/whatever one.
  • Check the diagnostic notification can be displayed, dismissed, opened and is removed when you leave the troubleshooting notifications screen.

Any other use case that comes to mind.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 14

Checklist

Copy link
Contributor

github-actions bot commented May 27, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/tLt9yS

Copy link

codecov bot commented May 27, 2024

Codecov Report

Attention: Patch coverage is 68.45426% with 100 lines in your changes are missing coverage. Please review.

Project coverage is 75.35%. Comparing base (436a876) to head (d7e38cf).
Report is 40 commits behind head on develop.

Files Patch % Lines
...push/impl/notifications/NotificationDataFactory.kt 70.00% 17 Missing and 13 partials ⚠️
...mpl/notifications/NotificationBroadcastReceiver.kt 0.00% 24 Missing ⚠️
...ations/factories/action/QuickReplyActionFactory.kt 0.00% 14 Missing ⚠️
.../notifications/DefaultNotificationDrawerManager.kt 69.44% 5 Missing and 6 partials ⚠️
...mpl/notifications/factories/NotificationCreator.kt 87.93% 2 Missing and 5 partials ⚠️
...es/push/impl/notifications/NotificationRenderer.kt 86.04% 2 Missing and 4 partials ⚠️
...raries/push/impl/push/OnNotifiableEventReceived.kt 0.00% 3 Missing ⚠️
...otifications/SystemNotificationsEnabledProvider.kt 0.00% 2 Missing ⚠️
...ent/android/features/call/CallForegroundService.kt 0.00% 1 Missing ⚠️
...ement/android/libraries/push/impl/di/PushModule.kt 0.00% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2924      +/-   ##
===========================================
+ Coverage    75.24%   75.35%   +0.10%     
===========================================
  Files         1550     1546       -4     
  Lines        36968    36790     -178     
  Branches      7156     7119      -37     
===========================================
- Hits         27817    27723      -94     
+ Misses        5414     5346      -68     
+ Partials      3737     3721      -16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jmartinesp jmartinesp marked this pull request as ready for review May 28, 2024 09:26
@jmartinesp jmartinesp requested a review from a team as a code owner May 28, 2024 09:26
@jmartinesp jmartinesp requested review from ganfra and removed request for a team May 28, 2024 09:26
@bmarty bmarty requested review from bmarty and removed request for ganfra May 28, 2024 09:28
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Some first remarks. There is a regression regarding shouldIgnoreEventInRoom, please see my comment.
I keep testing the application.

import javax.inject.Inject

/**
* Remove notifications.bin file, used to store notification data locally.
Copy link
Member

Choose a reason for hiding this comment

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

Perfect, thanks!

migration.migrate()

// Check that the file has been deleted
assertThat(file.exists()).isFalse()
Copy link
Member

Choose a reason for hiding this comment

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

Just to ensure that the test behaves as expected, I would add

assertThat(file.exists()).isTrue()

before invoking migration.migrate()

Copy link
Member Author

Choose a reason for hiding this comment

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

if (NotificationConfig.SUPPORT_JOIN_DECLINE_INVITE) {
addAction(rejectInvitationActionFactory.create(inviteNotifiableEvent))
addAction(acceptInvitationActionFactory.create(inviteNotifiableEvent))
}
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for un-commenting this and wrtting the code which does the actions!

@@ -59,16 +59,16 @@ class AndroidMediaPreProcessorTest {
assertThat(data.file.path).endsWith("image.png")
val info = data as MediaUploadInfo.Image
// Computing thumbnailFile is failing with Robolectric
assertThat(info.thumbnailFile).isNull()
assertThat(info.thumbnailFile).isNotNull()
Copy link
Member

Choose a reason for hiding this comment

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

Maybe remove the comment above?

Copy link
Member Author

Choose a reason for hiding this comment

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

@Provides
fun provideNotificationCompatManager(@ApplicationContext context: Context): NotificationManagerCompat {
return NotificationManagerCompat.from(context)
}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe Inject NotificationManagerCompat at some other places? You can look for NotificationManagerCompat.from to see where.

Copy link
Member Author

Choose a reason for hiding this comment

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

}

override fun count(): Int {
return getAllNotifications().size
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return getAllNotifications().size
return getNotificationsForSession(sessionId).size

Copy link
Member Author

Choose a reason for hiding this comment

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

val type = when (it) {
is InviteNotifiableEvent -> ProcessedEvent.Type.KEEP
is NotifiableMessageEvent -> when {
it.shouldIgnoreEventInRoom(appState) -> {
Copy link
Member

Choose a reason for hiding this comment

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

The call to shouldIgnoreEventInRoom was useful.
Now the notifications for new events are displayed even when the user is currently watching the room timeline.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, true. I'll have to restore it, thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

@jmartinesp jmartinesp requested a review from bmarty May 28, 2024 13:55
@jmartinesp jmartinesp force-pushed the misc/jme/simplify-notification-rendering branch from e10832a to d7e38cf Compare May 28, 2024 14:28
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Member

@bmarty bmarty 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 update!

@bmarty bmarty added the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 29, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 29, 2024
@jmartinesp jmartinesp enabled auto-merge (squash) May 29, 2024 07:44
@jmartinesp jmartinesp merged commit 04e5031 into develop May 29, 2024
24 of 25 checks passed
@jmartinesp jmartinesp deleted the misc/jme/simplify-notification-rendering branch May 29, 2024 08:03
bmarty added a commit that referenced this pull request May 29, 2024
bmarty added a commit that referenced this pull request May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants