Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ public override void InitializeView(IView parent)
{
base.InitializeView(parent);
tree.InitializeView(this);
}

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.

if (Repository == null)
return;

Expand Down