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

Added projectRefresh event when project tree is refreshed but project root has not changed. #4815

Merged
merged 2 commits into from
Sep 4, 2013
Merged

Added projectRefresh event when project tree is refreshed but project root has not changed. #4815

merged 2 commits into from
Sep 4, 2013

Conversation

zaggino
Copy link
Contributor

@zaggino zaggino commented Aug 18, 2013

I need an event like this for my git extension which hooks on project tree and displays branch information from git. I have not found any other way to hook onto this.

@ghost ghost assigned njx Aug 19, 2013
@peterflynn
Copy link
Member

If the idea is to get notifications when files are added/deleted/renamed, hanging those notifications off of ProjectManager doesn't seem ideal. But OTOH, once we add file watchers we'll probably have a whole different API for file-change notifications, so maybe it's not so bad to notify from ProjectManager for now & then deprecate it later...?

@WebsiteDeveloper
Copy link
Contributor

@peterflynn @zaggino i already added an extension which updates the file tree, maybe when the new proposed extension api is in place you could hook in to change events there.
By the way the extension is called FileWatcher

@zaggino
Copy link
Contributor Author

zaggino commented Aug 19, 2013

@peterflynn @WebsiteDeveloper my problem with hooking on any file change/add/delete/rename actions is that when user switches branches on git, none of this occurs. All files might be exactly the same on two different branches. Right now user has to change branches outside of brackets (I haven't implemented that yet but it's in plan though) and when he goes back to brackets, right clicking on the file tree and using "Refresh File Tree" won't help him, because there's no event to hook on. Maybe the event should be placed somewhere else but this seemed like a good place to me and it works fine.

@@ -920,6 +920,7 @@ define(function (require, exports, module) {
$(exports).triggerHandler({ type: "projectOpen", promises: promises }, [_projectRoot]);
$.when.apply($, promises).then(result.resolve, result.reject);
} else {
$(exports).triggerHandler("projectRefresh", _projectRoot);
Copy link

Choose a reason for hiding this comment

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

I wonder if it would make sense to trigger this in the projectOpen case as well (i.e., move it out of the if), so someone who just wants to know when the tree has been updated wouldn't have to listen to both projectOpen and projectRefresh.

Copy link

Choose a reason for hiding this comment

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

Also, could you add documentation for this to the comment at the top of the file where we list other events dispatched by ProjectManager?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have multiple actions assigned to projectOpen and they are not all the same as projectRefresh so putting it out of the if would make some things run when they are actually not required. I'd prefer to keep these events separate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the other side, projectRefresh is (in my case) a subset of projectOpen so putting it out of the if would be fine, in a case that projectRefresh handlers will be always launched after projectOpen handlers.

Copy link

Choose a reason for hiding this comment

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

Yeah, I guess I can see it either way. Logically, "refresh" is different from "open", so it makes sense to keep them separate.

@njx
Copy link

njx commented Aug 20, 2013

Initial review done. I think it's okay to add this because it's different from individual file notifications--it's specifically saying that the UI of the file tree has been torn down and rebuilt, and extensions that are annotating the tree might need to reapply themselves.

@zaggino
Copy link
Contributor Author

zaggino commented Aug 20, 2013

@njx Added the docs for the event.

@zaggino
Copy link
Contributor Author

zaggino commented Aug 27, 2013

@njx can you take a second look at this?

I can move the event out of the if-else if desired.

@njx
Copy link

njx commented Aug 29, 2013

Sorry, been busy. Will try to get to this soon.

@njx
Copy link

njx commented Sep 4, 2013

Seems fine. I'm going to push up another commit to tweak the comment after merging this. Thanks.

njx pushed a commit that referenced this pull request Sep 4, 2013
Added projectRefresh event when project tree is refreshed but project root has not changed.
@njx njx merged commit 9e97f55 into adobe:master Sep 4, 2013
@zaggino
Copy link
Contributor Author

zaggino commented Sep 4, 2013

Thanks @njx

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.

4 participants