Code refactoring

This commit is contained in:
Jaex 2022-12-07 18:29:41 +03:00
parent 59b30f7062
commit 63a5d8dfd3
2 changed files with 68 additions and 66 deletions

View file

@ -1086,7 +1086,10 @@ private bool OAuth2Complete(IOAuth2Basic uploader, string code, OAuthControl con
private async Task<OAuth2Info> OAuth2Loopback(IOAuth2Loopback oauth) private async Task<OAuth2Info> OAuth2Loopback(IOAuth2Loopback oauth)
{ {
OAuthListener listener = new OAuthListener(oauth); try
{
using (OAuthListener listener = new OAuthListener(oauth))
{
bool result = await listener.ConnectAsync(); bool result = await listener.ConnectAsync();
this.ForceActivate(); this.ForceActivate();
@ -1096,6 +1099,13 @@ private async Task<OAuth2Info> OAuth2Loopback(IOAuth2Loopback oauth)
{ {
return listener.OAuth.AuthInfo; return listener.OAuth.AuthInfo;
} }
}
}
catch (Exception e)
{
DebugHelper.WriteException(e);
e.ShowError();
}
return null; return null;
} }

View file

@ -52,8 +52,6 @@ public void Dispose()
} }
public async Task<bool> ConnectAsync() public async Task<bool> ConnectAsync()
{
try
{ {
Dispose(); Dispose();
Code = null; Code = null;
@ -119,12 +117,6 @@ public async Task<bool> ConnectAsync()
{ {
return await Task.Run(() => OAuth.GetAccessToken(Code)); return await Task.Run(() => OAuth.GetAccessToken(Code));
} }
}
catch (Exception e)
{
DebugHelper.WriteException(e);
e.ShowError();
}
return false; return false;
} }