mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 13:55:43 +00:00
Bug 528343 - Tabs don't sync
Set the current client on any tab change for tracker.changedIDs and reset that when sync finishes. --HG-- extra : rebase_source : 3100141bc1fdfaaa959b5f990a9538527761aace
This commit is contained in:
parent
00cc35abdf
commit
9a15bcc16b
@ -79,6 +79,11 @@ TabEngine.prototype = {
|
|||||||
this._store.wipe();
|
this._store.wipe();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_syncFinish: function _syncFinish() {
|
||||||
|
SyncEngine.prototype._syncFinish.call(this);
|
||||||
|
this._tracker.resetChanged();
|
||||||
|
},
|
||||||
|
|
||||||
/* The intent is not to show tabs in the menu if they're already
|
/* The intent is not to show tabs in the menu if they're already
|
||||||
* open locally. There are a couple ways to interpret this: for
|
* open locally. There are a couple ways to interpret this: for
|
||||||
* instance, we could do it by removing a tab from the list when
|
* instance, we could do it by removing a tab from the list when
|
||||||
@ -349,6 +354,7 @@ TabTracker.prototype = {
|
|||||||
|
|
||||||
_TabTracker_init: function TabTracker__init() {
|
_TabTracker_init: function TabTracker__init() {
|
||||||
this._init();
|
this._init();
|
||||||
|
this.resetChanged();
|
||||||
|
|
||||||
// Make sure "this" pointer is always set correctly for event listeners
|
// Make sure "this" pointer is always set correctly for event listeners
|
||||||
this.onTabOpened = Utils.bind2(this, this.onTabOpened);
|
this.onTabOpened = Utils.bind2(this, this.onTabOpened);
|
||||||
@ -421,34 +427,33 @@ TabTracker.prototype = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_upScore: function _upScore(amount) {
|
||||||
|
this.score += amount;
|
||||||
|
this._changedIDs[Clients.clientID] = true;
|
||||||
|
},
|
||||||
|
|
||||||
onTabOpened: function TabTracker_onTabOpened(event) {
|
onTabOpened: function TabTracker_onTabOpened(event) {
|
||||||
// Store a timestamp in the tab to track when it was last used
|
// Store a timestamp in the tab to track when it was last used
|
||||||
this._log.trace("Tab opened.");
|
this._log.trace("Tab opened.");
|
||||||
event.target.setAttribute(TAB_TIME_ATTR, event.timeStamp);
|
event.target.setAttribute(TAB_TIME_ATTR, event.timeStamp);
|
||||||
//this._log.debug("Tab timestamp set to " + event.target.getAttribute(TAB_TIME_ATTR) + "\n");
|
this._upScore(1);
|
||||||
this.score += 1;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onTabClosed: function TabTracker_onTabSelected(event) {
|
onTabClosed: function TabTracker_onTabSelected(event) {
|
||||||
//this._log.trace("Tab closed.\n");
|
this._log.trace("Tab closed.");
|
||||||
this.score += 1;
|
this._upScore(1);
|
||||||
},
|
},
|
||||||
|
|
||||||
onTabSelected: function TabTracker_onTabSelected(event) {
|
onTabSelected: function TabTracker_onTabSelected(event) {
|
||||||
// Update the tab's timestamp
|
// Update the tab's timestamp
|
||||||
this._log.trace("Tab selected.");
|
this._log.trace("Tab selected.");
|
||||||
//this._log.trace("Tab selected.\n");
|
|
||||||
event.target.setAttribute(TAB_TIME_ATTR, event.timeStamp);
|
event.target.setAttribute(TAB_TIME_ATTR, event.timeStamp);
|
||||||
//this._log.debug("Tab timestamp set to " + event.target.getAttribute(TAB_TIME_ATTR) + "\n");
|
this._upScore(1);
|
||||||
this.score += 1;
|
|
||||||
},
|
},
|
||||||
// TODO: Also listen for tabs loading new content?
|
// TODO: Also listen for tabs loading new content?
|
||||||
|
|
||||||
get changedIDs() {
|
get changedIDs() this._changedIDs,
|
||||||
// Only mark the current client as changed if we tracked changes
|
|
||||||
let obj = {};
|
// Provide a way to empty out the changed ids
|
||||||
if (this.score > 0)
|
resetChanged: function resetChanged() this._changedIDs = {}
|
||||||
obj[Clients.clientID] = true;
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user