mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Utils.CatchAndLog. Nexus/LL downloaders use in login commands
This commit is contained in:
@ -129,6 +129,30 @@ namespace Wabbajack.Common
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void CatchAndLog(Action a)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
a();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Utils.Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task CatchAndLog(Func<Task> f)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await f();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Utils.Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// MurMur3 hashes the file pointed to by this string
|
/// MurMur3 hashes the file pointed to by this string
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -40,8 +40,12 @@ namespace Wabbajack.Lib.Downloaders
|
|||||||
|
|
||||||
public LoversLabDownloader()
|
public LoversLabDownloader()
|
||||||
{
|
{
|
||||||
TriggerLogin = ReactiveCommand.Create(async () => await Utils.Log(new RequestLoversLabLogin()).Task, IsLoggedIn.Select(b => !b).ObserveOn(RxApp.MainThreadScheduler));
|
TriggerLogin = ReactiveCommand.CreateFromTask(
|
||||||
ClearLogin = ReactiveCommand.Create(() => Utils.DeleteEncryptedJson("loverslabcookies"), IsLoggedIn.ObserveOn(RxApp.MainThreadScheduler));
|
execute: () => Utils.CatchAndLog(async () => await Utils.Log(new RequestLoversLabLogin()).Task),
|
||||||
|
canExecute: IsLoggedIn.Select(b => !b).ObserveOn(RxApp.MainThreadScheduler));
|
||||||
|
ClearLogin = ReactiveCommand.Create(
|
||||||
|
execute: () => Utils.CatchAndLog(() => Utils.DeleteEncryptedJson("loverslabcookies")),
|
||||||
|
canExecute: IsLoggedIn.ObserveOn(RxApp.MainThreadScheduler));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,32 +20,29 @@ namespace Wabbajack.Lib.Downloaders
|
|||||||
private UserStatus _status;
|
private UserStatus _status;
|
||||||
private NexusApiClient _client;
|
private NexusApiClient _client;
|
||||||
|
|
||||||
public NexusDownloader()
|
|
||||||
{
|
|
||||||
TriggerLogin = ReactiveCommand.Create(async () => await NexusApiClient.RequestAndCacheAPIKey(), IsLoggedIn.Select(b => !b).ObserveOn(RxApp.MainThreadScheduler));
|
|
||||||
ClearLogin = ReactiveCommand.Create(() => Utils.DeleteEncryptedJson("nexusapikey"), IsLoggedIn.ObserveOn(RxApp.MainThreadScheduler));
|
|
||||||
}
|
|
||||||
|
|
||||||
public IObservable<bool> IsLoggedIn => Utils.HaveEncryptedJsonObservable("nexusapikey");
|
public IObservable<bool> IsLoggedIn => Utils.HaveEncryptedJsonObservable("nexusapikey");
|
||||||
|
|
||||||
public string SiteName => "Nexus Mods";
|
public string SiteName => "Nexus Mods";
|
||||||
|
|
||||||
public string MetaInfo
|
public string MetaInfo => "";
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Uri SiteURL => new Uri("https://www.nexusmods.com");
|
public Uri SiteURL => new Uri("https://www.nexusmods.com");
|
||||||
|
|
||||||
public Uri IconUri => new Uri("https://www.nexusmods.com/favicon.ico");
|
public Uri IconUri => new Uri("https://www.nexusmods.com/favicon.ico");
|
||||||
|
|
||||||
public ICommand TriggerLogin { get; }
|
public ICommand TriggerLogin { get; }
|
||||||
public ICommand ClearLogin { get; }
|
public ICommand ClearLogin { get; }
|
||||||
|
|
||||||
|
public NexusDownloader()
|
||||||
|
{
|
||||||
|
TriggerLogin = ReactiveCommand.CreateFromTask(
|
||||||
|
execute: () => Utils.CatchAndLog(NexusApiClient.RequestAndCacheAPIKey),
|
||||||
|
canExecute: IsLoggedIn.Select(b => !b).ObserveOn(RxApp.MainThreadScheduler));
|
||||||
|
ClearLogin = ReactiveCommand.Create(
|
||||||
|
execute: () => Utils.CatchAndLog(() => Utils.DeleteEncryptedJson("nexusapikey")),
|
||||||
|
canExecute: IsLoggedIn.ObserveOn(RxApp.MainThreadScheduler));
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<AbstractDownloadState> GetDownloaderState(dynamic archiveINI)
|
public async Task<AbstractDownloadState> GetDownloaderState(dynamic archiveINI)
|
||||||
{
|
{
|
||||||
var general = archiveINI?.General;
|
var general = archiveINI?.General;
|
||||||
|
@ -45,6 +45,9 @@
|
|||||||
<LangVersion>7.3</LangVersion>
|
<LangVersion>7.3</LangVersion>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||||
|
<WarningsAsErrors>CS4014</WarningsAsErrors>
|
||||||
|
<NoWarn>CS1998</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
<OutputPath>bin\x64\Release\</OutputPath>
|
<OutputPath>bin\x64\Release\</OutputPath>
|
||||||
@ -55,6 +58,8 @@
|
|||||||
<LangVersion>7.3</LangVersion>
|
<LangVersion>7.3</LangVersion>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<WarningsAsErrors>CS4014</WarningsAsErrors>
|
||||||
|
<NoWarn>CS1998</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="MongoDB.Bson">
|
<Reference Include="MongoDB.Bson">
|
||||||
|
Reference in New Issue
Block a user