Clean up mozL10n API use in bluetooth

RESOLVED FIXED

Status

defect
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: zbraniecki, Assigned: iliu)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

I'm trying to clean up all mozL10n.ready uses. It seems that:

- deviceList.js waits on mozL10n.ready
- transfer.js waits for localized event

== Transfer.js ==

Now, transfer.js at initialization seem to only set an observer on 'activity'. Guarding it with the eventlistener on 'localized' puts you at risk if the localized gets fired before transfer.js which is entirely possible.

We're going to introduce mozL10n.once helper in bug 993189 which fires the callback as soon as localized is ready and does it only once. 

I think that transfer.js should either use mozL10n.once or should not be guarded at all if it does not fire any l10n related activities (which I'm not sure if it does - from deviceList.js ?)

== DeviceList.js ==

deviceList.js is wrapped in mozL10n.ready which will refire on locale change, but it seems that the initialization code does not fire any localization related code.

I think that deviceList.js should either use mozL10n.once or should not be guarded at all.

I'm not sure when transfer.html is displayed and the methods like onDeviceFound, newListItem or bt_getPairedSuccess) are called but the code that calls them should be wrapped in mozL10n.ready to ensure retranslation on language change.
Ian: can you help me clean up the mozL10n API uses here?

In particular, we should use:

 - mozL10n.once - for any code that should wait for localization resources and be fired once
 - mozL10n.ready - for any code that should wait for localization resources and be fired once they are available and later on each language change.
Flags: needinfo?(iliu)
Blocks: 993188
Blocks: 1000593
No longer blocks: 993188
Gina, can you help me here? I need a few answers before I can work on the patch.
Flags: needinfo?(gyeh)
Sorry, I wish I could... :(

Let me pass the questions to Ian. He's going to answer them for you.
Flags: needinfo?(gyeh)
Hi Zbigniew, I'm able to take the issue for using correct mozL10n API for the two js files. And I will give a pull request for reviewing if you don't mind the reviewing work. Thanks.
Assignee: nobody → iliu
Flags: needinfo?(iliu)
Abaolutely! Please, go for it! I'll be happy to help with the API or reviews :)
Ian: any progress on that?
Flags: needinfo?(iliu)
Depends on: 1000806
Just give a pull request for review. And make sure the unit test passed.
Status: NEW → ASSIGNED
Flags: needinfo?(iliu)
Posted file pull request 19526
Arthur, could you please help to review the pull request? This is a small change for mozl10n API. And revised transfer_test for removing dispatch 'localised' event itself. Thanks.
Attachment #8426843 - Flags: review?(arthur.chen)
(In reply to Ian Liu [:ianliu] from comment #8)
> 'localised' event itself. Thanks.
wording ^---- localized
Comment on attachment 8426843 [details] [review]
pull request 19526

Looks good to me, thanks.
Attachment #8426843 - Flags: review?(arthur.chen) → review+
Since the pr is landed, we can close the issue now.

Gaia/master:  78977eb8d43beed1bad709a70cee3b0c4293056d
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Component: Bluetooth → Gaia::Bluetooth File Transfer
You need to log in before you can comment on or make changes to this bug.