Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 3ddd249

Browse files
committed
Immediately dispose views that aren't meant to stick around
1 parent 80dbba0 commit 3ddd249

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/GitHub.App/Controllers/UIController.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ internal enum Trigger
105105
readonly IUIFactory factory;
106106
readonly IUIProvider uiProvider;
107107
readonly IRepositoryHosts hosts;
108-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
109108
readonly IConnectionManager connectionManager;
110109

111110
readonly CompositeDisposable disposables = new CompositeDisposable();
@@ -333,7 +332,8 @@ void ConfigureUIHandlingStates()
333332
.OnEntryFrom(triggers[Trigger.PRDetail], (arg, tr) => RunView(UIViewType.PRDetail, CalculateDirection(tr), arg))
334333
.PermitDynamic(Trigger.Next, () => Go(Trigger.Next))
335334
.PermitDynamic(Trigger.Cancel, () => Go(Trigger.Cancel))
336-
.PermitDynamic(Trigger.Finish, () => Go(Trigger.Finish));
335+
.PermitDynamic(Trigger.Finish, () => Go(Trigger.Finish))
336+
.OnExit(() => DisposeView(activeFlow, UIViewType.PRDetail));
337337

338338
uiStateMachine.Configure(UIViewType.PRCreation)
339339
.OnEntry(tr => RunView(UIViewType.PRCreation, CalculateDirection(tr)))
@@ -622,6 +622,17 @@ void DisposeFlow(UIControllerFlow flow)
622622
list.Clear();
623623
}
624624

625+
void DisposeView(UIControllerFlow flow, UIViewType type)
626+
{
627+
var list = GetObjectsForFlow(flow);
628+
IUIPair uipair = null;
629+
if (list.TryGetValue(type, out uipair))
630+
{
631+
list.Remove(type);
632+
uipair.Dispose();
633+
}
634+
}
635+
625636
void RunView(UIViewType viewType, LoadDirection direction, ViewWithData arg = null)
626637
{
627638
if (requestedTarget?.ViewType == viewType)

0 commit comments

Comments
 (0)