Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Conversation

@StanleyGoldman
Copy link
Contributor

@StanleyGoldman StanleyGoldman commented Jul 13, 2017

Fixes: #132

@StanleyGoldman StanleyGoldman force-pushed the fixes/changes-view-refresh-initialize branch from 2dac6e9 to e2ddd68 Compare July 13, 2017 21:45
@StanleyGoldman StanleyGoldman force-pushed the fixes/changes-view-refresh-initialize branch from e2ddd68 to fe565bd Compare July 13, 2017 21:47
@StanleyGoldman StanleyGoldman changed the title Fixes to refresh ChangesView OnEnable Fixes to refresh ChangesView on start Jul 13, 2017
@StanleyGoldman StanleyGoldman requested a review from shana July 13, 2017 21:58

public override void OnEnable()
{
base.OnEnable();
Copy link
Member

Choose a reason for hiding this comment

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

Probably don't want to just to this always at initialize, since it calls Repository Refresh and all views get initialized. The logic of doing this on enable is correct, it's just that OnEnable might get called before the Repository instance is actually set, which means that we need to also do this whenever OnGUI is called. #91 introduces some methods that get called to update handlers and data, and the logic then becomes like this:

public override void OnEnable()
{
base.OnEnable();
AttachHandlers(Repository);
}
public override void OnDisable()
{
base.OnDisable();
DetachHandlers(Repository);
}
public override void OnRepositoryChanged(IRepository oldRepository)
{
base.OnRepositoryChanged(oldRepository);
DetachHandlers(oldRepository);
AttachHandlers(Repository);
}
private void AttachHandlers(IRepository repository)
{
if (repository == null)
return;
repository.OnLocalBranchListChanged += RunRefreshEmbeddedOnMainThread;
repository.OnActiveBranchChanged += HandleRepositoryBranchChangeEvent;
repository.OnActiveRemoteChanged += HandleRepositoryBranchChangeEvent;
}
private void DetachHandlers(IRepository repository)
{
if (repository == null)
return;
repository.OnLocalBranchListChanged -= RunRefreshEmbeddedOnMainThread;
repository.OnActiveBranchChanged -= HandleRepositoryBranchChangeEvent;
repository.OnActiveRemoteChanged -= HandleRepositoryBranchChangeEvent;
}

I could have sworn that that PR had already landed in master, really confused how it's not there yet, so that needs to land in order for these refresh bugs to get fixed.

Copy link
Member

@shana shana left a comment

Choose a reason for hiding this comment

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

There's a better fix that should have been in master already, bleh :/ Added comment about that on the line.

@StanleyGoldman
Copy link
Contributor Author

Closing this out in favor of #91

@StanleyGoldman StanleyGoldman deleted the fixes/changes-view-refresh-initialize branch August 1, 2017 11:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants