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

Commit 79507a3

Browse files
Controlling the close action with a flag
1 parent e9f7f09 commit 79507a3

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PopupWindow.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public enum PopupViewType
1414
AuthenticationView
1515
}
1616

17+
[SerializeField] private bool shouldCloseOnFinish;
1718
[SerializeField] private PopupViewType activeViewType;
18-
1919
[SerializeField] private AuthenticationView authenticationView;
2020
[SerializeField] private PublishView publishView;
2121
[SerializeField] private LoadingView loadingView;
@@ -44,11 +44,6 @@ private void Open(PopupViewType popupViewType, Action<bool> onClose)
4444
OnClose.SafeInvoke(false);
4545
OnClose = null;
4646

47-
onClose = onClose ?? (b => {
48-
Logger.Trace("Closing Window");
49-
Close();
50-
});
51-
5247
Logger.Trace("OpenView: {0}", popupViewType.ToString());
5348

5449
var viewNeedsAuthentication = popupViewType == PopupViewType.PublishView;
@@ -61,12 +56,13 @@ private void Open(PopupViewType popupViewType, Action<bool> onClose)
6156
Logger.Trace("User validated opening view");
6257

6358
OpenInternal(popupViewType, onClose);
59+
shouldCloseOnFinish = true;
6460

6561
}, exception => {
6662

6763
Logger.Trace("User required validation opening AuthenticationView");
6864

69-
Open(PopupViewType.AuthenticationView, completedAuthentication => {
65+
OpenInternal(PopupViewType.AuthenticationView, completedAuthentication => {
7066

7167
if (completedAuthentication)
7268
{
@@ -75,11 +71,13 @@ private void Open(PopupViewType popupViewType, Action<bool> onClose)
7571
Open(popupViewType, onClose);
7672
}
7773
});
74+
shouldCloseOnFinish = false;
7875
});
7976
}
8077
else
8178
{
8279
OpenInternal(popupViewType, onClose);
80+
shouldCloseOnFinish = true;
8381
}
8482
}
8583

@@ -177,6 +175,13 @@ public override void Finish(bool result)
177175
{
178176
OnClose.SafeInvoke(result);
179177
OnClose = null;
178+
179+
if (shouldCloseOnFinish)
180+
{
181+
shouldCloseOnFinish = false;
182+
Close();
183+
}
184+
180185
base.Finish(result);
181186
}
182187

0 commit comments

Comments
 (0)