New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revamp NTT's force-compatiblity feature. Fixes #52. #82
Revamp NTT's force-compatiblity feature. Fixes #52. #82
Conversation
@@ -493,14 +493,22 @@ openPushlog: function() { | |||
|
|||
toggleCompatibility: function() { | |||
var forceCompat = nightly.preferences.getBoolPref("disableCheckCompatibility"); | |||
nightly.preferences.setBoolPref("disableCheckCompatibility", !forceCompat); | |||
var os = Components.classes["@mozilla.org/observer-service;1"]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has been named obs
across the Firefox codebase. I would propose we do the same here, which makes it easier for us later to replace the instances with Services.obs.
- renamed 'os' to 'obs' - moved observer code to an object - shortened Components.* - formatted foreign code - renamed preference constants - moved version()
Added commit 392a9b8 - Addressing comments, round 1. |
self.obs.notifyObservers(null, "nttACS", null); | ||
} | ||
} | ||
AddonManager.getAddonsByTypes(null, countPendingAddonsAndNotifyToRestartCallback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The number of characters in function name countPendingAddonsAndNotifyToRestartCallback
is too damn high.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest we move the callback inline. There is no reason to have it separate given that it is only used once.
Would you mind to update the pull for the latest version of the NTT code? We really missed that in the 3.4 release. :/ |
whimboo wrote:
Sure! :) |
This pull request can be automatically merged. Again. :) |
let startCount = count(); | ||
self.setCompatPrefs(); | ||
if (startCount != count()) { | ||
self.obs.notifyObservers(null, "nttACS", "restartNeeded"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest we send an object like { restart: true }
which will make it easier to extend the observer data later if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest we send an object ...
Are you sure? Please check notifyObservers()
documentation again! ;)
void notifyObservers(
in nsISupports aSubject,
in string aTopic,
in wstring someData
);
I could use JSON.parse()
here on the other side, if you really want to pass an object.
- JSONed observer data - version is now a property - space nits - Songbird exclusion note - filtering addons - not inlining long name function yet
- rework setCompatPrefsHelper
@whimboo |
@whimboo |
obs.removeObserver(restartObserver, "nttACS"); | ||
var parsedData = JSON.parse(data); | ||
if (parsedData && parsedData.restart) { | ||
nightlyApp.openNotification("nightly-compatibility-restart", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before we had if (nightlyApp.openNotification)
. Isn't that necessary anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before we had
if (nightlyApp.openNotification)
. Isn't that necessary anymore?
It's still around here! :)
The restartObserver
above is activated only if nightlyApp.openNotification
exists. See L491
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this if in here, so that we always send an observer notification. Other extensions may want to rely on the notification and then could benefit from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this if in here, so that we always send an observer notification. ...
?!
The nttAddonCompatibilityService
sends the notification in all case. See the other, sendNotification()
, notifyObject
related threads near at line L54
and L73
/L83
!
The restartObserver
here isn't always activated.
For example Songbird doesn't have nightlyApp.openNotification
implemented yet,
therefore nightly.toggleCompatibility
doesn't register for the restart notification.
It simply discards. :)
But in Firefox case it will register the observer, and the PopupNotification/NotificationBox could open if restart would be needed after pref change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't matter which application has openNotification
available or not. If a restart is necessary we should fire the observer anyway. If the notification cannot be handled in observe
because the above method is not available, we can always skip it. But we should not stop sending the observer notification due to that reason. As I have mentioned above others may be very well interested in our notification too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should over-engineer it at this point. When we really only want to have it available internally, why can't we call it directly through it's object/instance? If the prompt has to happen async we can use setTimeout(fun, 0)
to trigger it, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case the component should find the most recent Tb, SM, Fx, ... window - if any - then it could call nightly.openNotification
.
But I'm still voting for drop this demand stuff from this pull, and let it born as a follow-up issue. Or simply leave it as is - a public interface.
And I still can't imagine what do you think how should I implement this interface privately. :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so lets rename the observer topic to _nttACS
which should make it clear it's somewhat private. Please file a follow-up where we can discuss another (better) solution. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so lets rename the observer topic to
_nttACS
...
Renamed, but not tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until this private interface doesn't get implemented (should file a follow-up issue) I move this obs
and restartObserver
into if (nightlyApp.openNotification)
section:
- to avoid confusion, because they belongs there
- due to performance :)
if(this.prefService.getBoolPref("nightly.disableCheckCompatibility")) | ||
this.version = this.appinfo.version.replace(/^([^\.]+\.[0-9]+[a-z]*).*/i, "$1"); | ||
|
||
if(this.prefService.getBoolPref(PREF_FORCE_COMPAT)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: a blank between if and the opening bracket.
- space nits - inline pending filter
Pull updated for the nits. |
- "nttACS" -> "_nttACS"
Grrr! Seems like the inline transformation of |
I'll have extremely little free time until at least Easter Monday. The two weeks after that I might have a little more slack. |
- not starting a boolean in isPendingAddon() - space nits
- not starting a boolean in isPendingAddon(), really
Bug hunted down.
|
- space nit
@whimboo |
- indentation
@@ -473,14 +473,25 @@ openPushlogSinceCurrentBuild: function() { | |||
|
|||
toggleCompatibility: function() { | |||
var forceCompat = nightly.preferences.getBoolPref("disableCheckCompatibility"); | |||
nightly.preferences.setBoolPref("disableCheckCompatibility", !forceCompat); | |||
var obs = Components.classes["@mozilla.org/observer-service;1"]. | |||
getService(Components.interfaces.nsIObserverService); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have an inconsistency here how we use Cc and Ci regarding their short and long names. If you feel fine please make it shorter here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see no inconsistency here reagrding to Cx
shortcuts.
Please note that nightly.js
doesn't have those shortcuts!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So please file a new issue which we can use to sync up all the files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have #87 already for styling. Should I file a new for code consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whatever works best for you. Is something else remaining now or can we can get this pull merged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to fix the two nits, so the pull request is not ready yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So please file a new issue which we can use to sync up all the files.
Filed #128.
Except the two nits we are very close to get this landed! |
- obs + restartObserver is relevant only in nightlyApp.openNotification case - nttAddonCompatibilityService space nits
Added commit 4bf06c6:
I hope you agree with that move in |
... |
Looks fine to me. Lets get it landed. |
Landed as ae9184f. |
Please note the following:
it's a draft!