Closed Bug 1111841 Opened 10 years ago Closed 9 years ago

Migrate Notifications to use the new NotificationHelper

Categories

(Firefox OS Graveyard :: Gaia, defect)

x86
All
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: zbraniecki, Unassigned, Mentored)

References

Details

(Whiteboard: [good first bug])

User Story

Switch all use cases of:

var title = navigator.mozL10n.get('bluetooth-pairing-request-now-title');
var body = navigator.mozL10n.get('unnamed-device');

var notification = new Notification(title, {
  body: body,
});

to:

NotificationHelper.send('bluetooth-pairing-request-now-title', {
  bodyL10n: 'unnamed-device'
});

Attachments

(2 files)

We have around 20 use cases where we create a localizable Notification using raw W3C API. In bug 1095109 we updated NotificationHelper to follow L10n API guidelines and we should transition all Notification uses to that helper API.
User Story: (updated)
Mentor: gandalf
Whiteboard: [good first bug]
I'm ready to work on this bug. Can you please point me to a code? This is my first bug!
You can find the code using grep -I -r "new Notification" ./apps/
Blocks: 1020138
Attached file grep-log
76 new Notification that needs to be changed
Zibi, I attached a plain text file with the coincidences found by grep that needs to be migrated. If there's no problem, I would like to work on this bug. Regards, Gio
Attached file Github PR
Attachment #8546380 - Flags: feedback?(gandalf)
Zibi, I attached a Github PR, could you review it and let me know what is wrong and what is ok? There are some files that needs to be changed too but I would like to know first if I am doing it right.
Hi Giovanny! Thanks for taking this bug. You seem to cover all cases, but I believe it would be better to start with a smaller number. In particular: - do not touch Notifications that are using mozbehavior. NotificationHelper does not cover that. Also, make sure to leave their tests as well - focus on cases of Notifications which are currently using mozL10n.get(l10nId) to translate their title or body. Those should be converted to NotificationHelper and use titleL10n and bodyL10n. - do not change property names from tag to tagL10n, icon to iconL10n etc. It's good to start small, so if you can identify first 10 cases and transform them, we can test your patch quicker, get reviews and land :)
Hi Zibi, So, the files inside apps/<app-name>/test must not be modified?
(In reply to Giovanny Andres Gongora Granada from comment #9) > Hi Zibi, > > So, the files inside apps/<app-name>/test must not be modified? Every test is testing a behavior of a JS code. Every Notification (or MockNotification) in test is related to a Notification in real code. When you update Notification code you may want to update related test, but focus on real code first and then let's fix matching tests :)
Zibi I changed some code in three files: apps/network-alerts/js/attention/attention.js apps/wappush/js/wappush.js apps/ringtones/js/share.js Could you review the pull request again and let me know if everything is ok to continue with other files or fix what is wrong in those modified?
Flags: needinfo?(gandalf)
That looks good! I like the scope :) Consider refactoring the prepareMessageTitle to return L10nAttrs object and use it for NotificationHelper. That would be a perfect size of a patch :)
Flags: needinfo?(gandalf)
I posted a comment in the PR, could you check it? Also, can you explain me more detailed how I can refactor the prepareMessageTitle? As I understand the refactor will be: from: var title = Utils.prepareMessageTitle(message); to: var title = navigator.mozL10n.setAttributes(message, l10n.id, l10n.args); Can you address me on this?
Flags: needinfo?(gandalf)
(In reply to Giovanny Andres Gongora Granada from comment #13) > I posted a comment in the PR, could you check it? Yup, responded. > Also, can you explain me > more detailed how I can refactor the prepareMessageTitle? > > As I understand the refactor will be: > > from: > var title = Utils.prepareMessageTitle(message); > > to: > var title = navigator.mozL10n.setAttributes(message, l10n.id, l10n.args); No, that will be more work. You need to refactor this function: https://github.com/mozilla-b2g/gaia/blob/2c3341a306e043490851cd8552ca95fea0417afc/apps/wappush/js/utils.js#L33-L50 so that it returns: return { id: 'dsds-notification-title-with-sim', args: { sim: simName, title: _title } } then, you need to update its uses: from: var title = Utils.prepareMessageTitle(message); NotificationHelper.send(title, ...); to: var titleL10n = Utils.prepareMessageTitle(message); NotificationHelper.send(titleL10n, ...); There are two uses of Utils.prepareMessageTitle. One is where you are working on, the other is in apps/wappush/js/cp_screen_helper.js Hope that helps!
Flags: needinfo?(gandalf)
Any progress on that?
Flags: needinfo?(gioyik)
Hi there, we are still getting many instances where localizations don't appear properly because of this. Is there any update on this please? thanks
Attachment #8546380 - Flags: feedback?(gandalf)
Assignee: gioyik → nobody
Flags: needinfo?(gioyik)
I'll take this one. I'll need some guidance to get started though, so let me know where I should go first! Thanks!
Depends on: 1220978
Depends on: 1220982
Depends on: 1220989
Depends on: 1223280
Depends on: 1223275
Depends on: 1223993
Depends on: 1224009
Depends on: 1226020
We don't have any more raw Notifications in ./apps or ./shared! Thanks a lot for help Heidi!
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: