Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Check for extensions updates #7330

Merged
merged 2 commits into from
Apr 22, 2014
Merged

Check for extensions updates #7330

merged 2 commits into from
Apr 22, 2014

Conversation

zaggino
Copy link
Contributor

@zaggino zaggino commented Mar 25, 2014

As mentioned here #6723

Ping @lkcampbell @larz0

image

P.S.: this is not a complete thing but I wanted to get it moving at least a bit (and design is ugly because I don't have a software to work with SVG :)) Feel free to push into this branch.

@larz0
Copy link
Member

larz0 commented Mar 25, 2014

Thanks @zaggino! I played with it, trying to make the number smaller so it won't cover the extension icon but made the number hard to read. I think we discussed that's it's okay to not include the number. Thoughts?

screen shot 2014-03-25 at 4 05 36 pm

@zaggino
Copy link
Contributor Author

zaggino commented Mar 25, 2014

Yes, we can remove the number completely. I think @lkcampbell mentioned just making the icon green and that's fine with me, but I didn't really know how to do it fast and didn't want to spent half a day with SVG thingy now :)

@larz0
Copy link
Member

larz0 commented Mar 26, 2014

We can just use span like what @peterflynn suggested originally like this (ignore font-size: 0, we should just remove the text):

screen shot 2014-03-25 at 5 08 42 pm

@larz0
Copy link
Member

larz0 commented Mar 26, 2014

It'll look like this:

screen shot 2014-03-25 at 5 10 03 pm

@zaggino
Copy link
Contributor Author

zaggino commented Mar 26, 2014

@larz0 done ;-)

@larz0 larz0 closed this Mar 26, 2014
@larz0 larz0 reopened this Mar 26, 2014
@zaggino
Copy link
Contributor Author

zaggino commented Mar 26, 2014

I have now realized that update check is done every time someone closes and opens the Brackets... Not only my new update check for extension but also the old check for new Sprint version... this is probably spamming the server? Ping @TomMalbran to clarify.

@larz0
Copy link
Member

larz0 commented Mar 26, 2014

I accidentally hit close!

Hopefully this can be merged pretty quickly.

@zaggino
Copy link
Contributor Author

zaggino commented Mar 26, 2014

Probably not so fast, I see these lines in master https://github.com/adobe/brackets/blob/master/src/brackets.js#L295-L305 as problematic. I don't think it's a good idea to do requests everytime Brackets are started - I do that quite a lot.

@zaggino
Copy link
Contributor Author

zaggino commented Mar 26, 2014

Also Travis says zaggino has NOT submitted the contributor license agreement ... what sorcery is this? 😕

@larz0
Copy link
Member

larz0 commented Mar 26, 2014

Hmm I think I saw an email about that from @redmunds.

@TomMalbran
Copy link
Contributor

@zaggino According to issue #6723 the idea was to call it every 24 hours, so it probably shouldn't call it on every launch. So you save the time you get an update and on you just start the timeout on every launch using that time. It should also get updated every time you open the registry and when you update extensions. In this case we should reset the timer. And finally, it might be a good idea to get the updates on the first launch after a Brackets update.

The Brackets updates and the Registry live on different servers and while the Brackets update request might be short, the registry might be a lot longer. So it should use a lot less bandwidth to call the brackets update than the registry. So it might make sense that one resets on every launch but the other one doesn't.

@TomMalbran
Copy link
Contributor

It might also be nice to add a new API to the registry to retrieve the data for a list of extensions, so that we don't need to get every single extension when only have a few installed. But that might be for another PR.

@zaggino
Copy link
Contributor Author

zaggino commented Mar 26, 2014

Ah, it actually does check for the 24 hours, but much more deeper in the code, I'll try to rewrite it a bit.

@zaggino
Copy link
Contributor Author

zaggino commented Mar 26, 2014

This works better now - check at most once a day + if extension is uninstalled or updated, do not show notification for it.

@redmunds
Copy link
Contributor

zaggino has NOT submitted the contributor license agreement

There's a bug in our CLA check script where all checks are failing. We're working on it.

@lkcampbell
Copy link
Contributor

Just my two cents on this, I always liked the design where the block turns completely green. This is a screenshot from issue #6723 as a comparison:

update-extension

@redmunds
Copy link
Contributor

Only changing the color is easy to miss for people who are partially colorblind (like me), so I like the idea of also adding a "+" to the icon.

@JeffryBooher
Copy link
Contributor

@TomMalbran can you take a look?

}

function launchAutomaticUpdate() {
var INTERVAL = 86520000; // repeat once a day, plus 2 minutes
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This in my opinion could be a lot shorter - like an hour or two. The real interval is limited to 24 hours for both branches of the code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update seems ok to be done every day or on every startup, we don't update all the time anyway and at most you get the update some hours later which isn't bad.

Notice that the registry is not in the same server as brackets.io and is not even owned by Adobe, is hosted by jrowny company. So we should ckeck wicth him about the bandwidth about checking a lot more often would be. Also, this might change with another API to request information about just the extensions required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this interval even to 5 milliseconds doesn't change that the requests are made just once every 24-hours. Currently it's like this:

Monday - update at 9:00 (the time gets saved in user preferences)
Tuesday - turn on PC at 8:55 (it's not 24 hours yet, so no update check, schedule update check 24 hours + 2 minutes from 8:55 to Wednesday 8:57 - no update check for almost 24 hours)

This is scenario in a case Brackets are not restarted entire day.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it might be simpler if we use an interval for Brackets updates which works like this and a timeout for Extensions updates, where the time is savedTime + oneDay - currentTime and is recreated after the updates are checked.

@zaggino
Copy link
Contributor Author

zaggino commented Mar 26, 2014

I agree with @lkcampbell that green icon and plus notification sign together would be better than just the latter one.

@larz0
Copy link
Member

larz0 commented Mar 26, 2014

Can we just use what we discussed at #6723? There's a lot of good points there.

@zaggino
Copy link
Contributor Author

zaggino commented Mar 26, 2014

@larz0 I wanted to make the green icon but I'm a fail graphics person. Is there a good reasonable free editor for Windows to work with SVG files?

@larz0
Copy link
Member

larz0 commented Mar 26, 2014

@zaggino Inkscape or Adobe Illustrator. Here's the SVG that you can use: http://cl.ly/1O2B2g150q35

@zaggino
Copy link
Contributor Author

zaggino commented Mar 26, 2014

Thanks 👍

@zaggino
Copy link
Contributor Author

zaggino commented Mar 26, 2014

Looks great now :)
image

@larz0
Copy link
Member

larz0 commented Mar 26, 2014

dancing-animals

@TomMalbran
Copy link
Contributor

@larz0 What do you want to see from #6723 here?

@zaggino Now that we don't show the extensions count, we don't need to check with the registry if the icon is already green.

@zaggino
Copy link
Contributor Author

zaggino commented Apr 1, 2014

Finally found your problem - it wasn't introduced by my changes. If you had installed version for Brackets 35 and latest version was for Brackets 99, update was always disabled before, even though version for Brackets 37 existed in the registry. I fixed it so after the fix you can update to version for Brackets 37 even though it's not the latest ;-)

I'd push here the fix and the tests for new methods but GitHub is down...
https://status.github.com/
image

[just for my reference]
https://drive.google.com/file/d/0B4bVP5AkPe-kR2g2QzIzaEtUQlE/edit?usp=sharing

@zaggino
Copy link
Contributor Author

zaggino commented Apr 2, 2014

Finally pushed - ready for another look @TomMalbran

@TomMalbran
Copy link
Contributor

No, that isn't the issue I was referring too. This change will allow you o install extensions not supported by Brackets. So you should undo that change, it is working fine. The issue is with the updates counter not with the actual updates. I'll explain it better:

Lets say that I am running Brackets 37 (not master, but the actual released code). Now lets say that I have an extension fully updated that supports version 37. Lets say that Brackets 38 will release a new awesome API which is already available in master. The extension author loves this API and decides to use it and releases a new version of his extension but that supports Brackets 38. Now the user gets a update notification that his extension has an update, but when he wants to update it he can't since it requires Brackets 38 and he has version 37. He can't upgrade Brackets and doesn't want to use the code from master, so he will not update it until the next Brackets release. The issue now is that since there is an update the extension icon turned green, and it will stay like that until the next release. So now the user won't be notified of any new updates for other extensions that might support Brackets 37 and that he would like to upgrade. This can happen a lot, specially when upgrading an extension to use new APIs, and have it ready for the next release.

So my point is, that we shouldn't count updates for extensions that can't be updated because your Brackets version doesn't supported. Is ok if you can't actually install it and that we show a disabled upgrade button in the manager. But both the counter in the manager and the icon in the sidebar shouldn't consider this extensions as updates. Notice that the counter in the dialog already counts them, but once we merge this, the problem can be a lot worse.

About the tests, I am not sure if it is a great idea to just implement them in already created tests. Would be better to have them in a new describe. Inside the same file.

Have you considered moving the extensions update functions to one of the extensibility files?

@zaggino
Copy link
Contributor Author

zaggino commented Apr 2, 2014

I really can't find the stuff you're talking about - please fix me what I'm doing wrong:

  1. All extensions updated - I see no updates - close Brackets
  2. Open extensions folder and git clone https://github.com/TomMalbran/brackets-fonts-viewer.git tommalbran.brackets-fonts-viewer
  3. cd tommalbran.brackets-fonts-viewer/
  4. git checkout 73e2011b10b96ab80a716d66cb51fa4232bc73ff
  5. Now I've got version 0.1.0 for brackets >=0.35.0
  6. Start Brackets (this branch)
  7. Open extension manager - 1 update available, icon turns green
  8. Update the font viewer - version 0.2.0 for brackets 0.38.0 is downloaded and installed.
  9. Restart
  10. No notifications immediately upon restart
  11. Open Extension registry
  12. No notifications about any updates
  13. Your extension is marked as this
    image

@zaggino
Copy link
Contributor Author

zaggino commented Apr 2, 2014

  1. wasn't possible before my fix

@TomMalbran
Copy link
Contributor

Oh, I see. I had version 0.1.0. So I could update it to version 0.2.0 and I can't get the next update since is not supported and it is not showed in count. Awesome, I thought it might have been another error. Sorry about that.

@zaggino
Copy link
Contributor Author

zaggino commented Apr 2, 2014

Ok. Tests have been moved into the new describe. I've looked at the code and I don't think there's anything I'd move but if you want to move some functions around just tell me which and to where :)

@zaggino
Copy link
Contributor Author

zaggino commented Apr 3, 2014

Rebased and ready for review @TomMalbran
Let me know if you want to move those functions somewhere, but I feel those timeouts and periodic checks are better placed in the UpdateNotification than ExtensionManager

@TomMalbran
Copy link
Contributor

Maybe it is ok there since you are only testing the new ExtensionManager functions. Unless we need more tests, the location is fine for now.

The code looks good to me, but I am not an expert in the Extensions Manager code, and this touches it a lot, so I am not sure if it might break something else. Maybe @njx could give it a fast look?

Also I don't know how we are on the next release, so I am not sure if we should wait for sprint 39 (we would have more time to test it) or if everything is fine to merge it for sprint 38.

@zaggino
Copy link
Contributor Author

zaggino commented Apr 10, 2014

We missed the 38 (c3f2b50) so this could be merged early into 39 to catch potentional problems, even though I doubt there should be any.

@TomMalbran
Copy link
Contributor

Yes, that was the plan. I forgot to post it here. The day I talked about it with Peter was going to probably be branch day, which at the end it wasnt, so there waasn't much time to test. This might seems like an easy feature but I think is a bit more complex and it touches some bits in extension manager that should be better tested. I'll give it a final look and merge it soon, since we are already in release 39.

@lkcampbell
Copy link
Contributor

@zaggino and @TomMalbran, I am really glad this feature is going in and I am also really glad that @zaggino did it instead of me ;).

Seriously though, thanks for all of your work on this.

@@ -506,39 +523,92 @@ define(function (require, exports, module) {
);
}

/**
* Gets an array of extensions that are currently installed and can be updated to a new version
* @return {Array} array of objects with properies id,installVersion,registryVersion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change the type to Array.<{id: string, installVersion: string, registryVersion: string}> and change the description a bit to not mention with properies id,installVersion,registryVersion?

@TomMalbran
Copy link
Contributor

@zaggino Sorry for the delay. I did a final review of the code and found a few nits. After those are fixed, I think we can finally merge this.

Updated design

Check registry at most once a day

Remove updated and uninstalled extensions from update list

Use new icon sprite

Calculate when an actual update should be launched

Calculate updateCompatible for extensions

toggle icon even when registry are downloaded through extension manager

checkForUpdate is now called directly on the startup as it was before

combine the functions

download only if there're no updates available

delete icon that is no longer user

This sorts installed extensions by updateAvailable (#6634)

align = in exports

add an empty line

use localeCompare instead of ifs

use Array instead of array for preferences

do not convert new preferences

move event listener to the bottom of the file

move function to the bottom to make JSLint happy

count only compatible updates for notification icon

add comments

fix tests that were failing after changes to the model.notifyCount

fix issue when update button is disabled but newer compatible version (not latest) exists

add tests for ExtensionManager.getAvailableUpdates() method

add tests for ExtensionManager.cleanAvailableUpdates() method

move new tests
@zaggino
Copy link
Contributor Author

zaggino commented Apr 22, 2014

@TomMalbran comments should be fixed now.

@TomMalbran
Copy link
Contributor

Ok. I am ready to merge this. If anything fails, we can fix it later :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants