mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-03 02:36:50 +13:00
Code refactoring
This commit is contained in:
parent
59b30f7062
commit
63a5d8dfd3
2 changed files with 68 additions and 66 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue