Closed Bug 1270102 Opened 8 years ago Closed 8 years ago

Broadcast messages to announce changes to Places

Categories

(Firefox OS Graveyard :: Gaia::System::Browser Chrome, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: benfrancis, Assigned: jovan.gerodetti, NeedInfo)

References

Details

Attachments

(1 file)

The homescreen needs to know when a pinned site or pinned page changes so that it can update itself.

I think we need to send messages using postMessage https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage on a BroadcastChannel https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel

The homescreen needs to know when a site or page is pinned or unpinned. It might also be useful to include the URL of the site or page which changed so that the homescreen can do something smarter than just reloading the whole list.
Jovan, do you think you'd be able to have a go at this?

Let me or Alberto know if you need some help.
Flags: needinfo?(titannanomail)
Flags: needinfo?(apastor)
Yes I think I can give it a try :)

Where should this message be broadcasted? 
In the system browser UI I guess, but which files should I check out to get started?
Flags: needinfo?(titannanomail) → needinfo?(bfrancis)
Great!

These actions are triggered from AppChrome:
pinSite https://github.com/mozilla-b2g/gaia/blob/kanikani/apps/system/js/app_chrome.js#L449
unpinSite https://github.com/mozilla-b2g/gaia/blob/kanikani/apps/system/js/app_chrome.js#L497
pinPage https://github.com/mozilla-b2g/gaia/blob/kanikani/apps/system/js/app_chrome.js#L406
unpinPage https://github.com/mozilla-b2g/gaia/blob/kanikani/apps/system/js/app_chrome.js#L428

But the actual database access takes place in Places:
pinSite https://github.com/mozilla-b2g/gaia/blob/kanikani/apps/system/js/places.js#L397
setPinned (for pages) https://github.com/mozilla-b2g/gaia/blob/kanikani/apps/system/js/places.js#L357

We probably want to send the messages once we know the database modification has actually happened, in a callback or when a Promise resolves.

Warning: This code is a bit of a mess at the moment as it's in transition from the old DataStores to the new IndexedDB database.
Flags: needinfo?(bfrancis)
Do Homescreen and System app share the same window object? 
Can I broadcast the event on the system app window object?
Flags: needinfo?(bfrancis)
Nope, they don't, but you can still broadcast messages via BroadcastChannel as both iframes are in the same domain. You can see an example on the Search app

https://github.com/mozilla-b2g/gaia/blob/kanikani/apps/search/js/search.js#L57

Let me know if you have any other question!
Flags: needinfo?(bfrancis)
Flags: needinfo?(apastor)
I finished the broadcasting part. I'd create a pull so one of you can have a look. 
Who should I set for review?
Flags: needinfo?(bfrancis)
Flags: needinfo?(apastor)
I finished the broadcasting part. I'd create a pull so one of you can have a look. 
Who should I set for review?
Great :) Either of us is fine, I'm happy to review this.
Flags: needinfo?(bfrancis)
did I messup the review flag? I can't find one on my patch.
Flags: needinfo?(bfrancis)
Assignee: nobody → titannanomail
Flags: needinfo?(apastor)
Attachment #8749162 - Flags: review?(bfrancis)
Comment on attachment 8749162 [details] [review]
[gaia] TitanNano:fix_1270102 > mozilla-b2g:kanikani

This is great! Thanks Jovan.

We'll want to figure out what to do when a site or page is unpinned, but this is a great start.
Flags: needinfo?(bfrancis)
Attachment #8749162 - Flags: review?(bfrancis) → review+
Landed on kanikani https://github.com/mozilla-b2g/gaia/commit/3322b12d0f173ebd1bf02e8a7c6685b537c0ef54
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
great! I'm interested to continue working on the homescreen. 
So if you have other bugs I can work on, I'll be happy to take a look that them :)
Flags: needinfo?(bfrancis)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: