Skip to content

Conversation

@jonalmeida
Copy link
Collaborator

Needs some love from releng to get us the Firebase keys into r-b, but it should work after that. 🎉

Pull Request checklist

Before merging checklist

  • Changelog: This PR includes a changelog entry or does not need one.

@jonalmeida jonalmeida requested a review from a team as a code owner August 13, 2019 17:13
@jonalmeida jonalmeida force-pushed the integrate-push-796 branch 2 times, most recently from 0af1898 to 12b2ddc Compare August 14, 2019 13:00
@jonalmeida jonalmeida added the 🕵️‍♀️ needs review PRs that need to be reviewed label Aug 30, 2019

// Pick a random ID for this notification so that different tabs do not clash.
@SuppressWarnings("MagicNumber")
val notificationId = (Math.random() * 100).toInt()
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use NotificationIds?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes please. :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wouldn't this give me the same id all the time? I don't have different tags, but I need new IDs generated for each tab sent.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, yeah, that is tricky. You could still create a different tag based on the URL every time. But that is also wasteful.

Anyhow, using random will just randomly replace other notifications and is not a good choice.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I took the NotificationManager from Fenix, so I wonder how that's working 🤔 .

I guess I should store the IDs in a map to avoid collisions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since we're using a unique tag for send tab, I added a simple notification ID counter that would always increment up. That should avoid notification ID collisions.


// Pick a random ID for this notification so that different tabs do not clash.
@SuppressWarnings("MagicNumber")
val notificationId = (Math.random() * 100).toInt()
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, yeah, that is tricky. You could still create a different tag based on the URL every time. But that is also wasteful.

Anyhow, using random will just randomly replace other notifications and is not a good choice.

/**
* Manages notification channels and allows displaying different types of notifications.
*/
class NotificationManager(private val context: Context) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're creating an NotificationManager, should DataReportingNotification also use this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh wow, when I rebased I didn't see this. I think it's fair to merge them together.

}

// Use an incrementing notification ID since they have the same tag.
var sendTabNotificationIdCount = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe more generic name if we're using this class for all notifications

Copy link
Contributor

@rocketsroger rocketsroger left a comment

Choose a reason for hiding this comment

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

LGTM. Some questions related to the new NotificationManager

Copy link
Contributor

@rocketsroger rocketsroger left a comment

Choose a reason for hiding this comment

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

🚢

@rocketsroger rocketsroger merged commit 243b38f into mozilla-mobile:master Dec 30, 2019
@jonalmeida jonalmeida deleted the integrate-push-796 branch December 30, 2019 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🕵️‍♀️ needs review PRs that need to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants