Skip to content

Commit

Permalink
feat: #16 & update tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
SolarianZ committed Aug 17, 2024
1 parent 95d2541 commit 324d076
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions Editor/Scripts/UrlEditWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private void FocusTitleField()

private void GetWebsiteTitle()
{
Assert.IsTrue(_getTitleTask == null);
Assert.IsTrue(_getTitleHttpClient == null && _getTitleTask == null);

_getTitleStatusLabel.text = null;

Expand All @@ -181,29 +181,27 @@ private void GetWebsiteTitle()
_getTitleStatusLabel.text = $"Getting title from {_getTitleUrl} ...";

_getTitleHttpClient = new HttpClient();
_getTitleHttpClient.Timeout = TimeSpan.FromSeconds(_getTitleTimeout);
try
{
_getTitleHttpClient.Timeout = TimeSpan.FromSeconds(_getTitleTimeout);
try
{
_getTitleTask = _getTitleHttpClient.GetStringAsync(_getTitleUrl);
}
catch (Exception e)
{
_getTitleStatusLabel.style.color = GetTextColor(true);
_getTitleStatusLabel.text = e.Message;
_getTitleTask = _getTitleHttpClient.GetStringAsync(_getTitleUrl);
}
catch (Exception e)
{
_getTitleStatusLabel.style.color = GetTextColor(true);
_getTitleStatusLabel.text = e.Message;

_getTitleHttpClient.Dispose();
_getTitleHttpClient = null;
_getTitleTask = null;
_getTitleHttpClient.Dispose();
_getTitleHttpClient = null;
_getTitleTask = null;

UDebug.LogException(e);
}
UDebug.LogException(e);
}
}

private void UpdateGetWebsiteTitle()
{
if (_getTitleTask == null)
if (_getTitleHttpClient == null || _getTitleTask == null)
{
return;
}
Expand Down Expand Up @@ -232,7 +230,7 @@ private void UpdateGetWebsiteTitle()

case TaskStatus.Canceled:
_getTitleStatusLabel.style.color = GetTextColor(false);
_getTitleStatusLabel.text = "Get the website title canceled";
_getTitleStatusLabel.text = "Timeout";

_getTitleHttpClient.Dispose();
_getTitleHttpClient = null;
Expand Down

0 comments on commit 324d076

Please sign in to comment.