diff --git a/ApplicationServices/UNTESTED/LibraryCommands.cs b/ApplicationServices/UNTESTED/LibraryCommands.cs index 6e370e54..a2ddd05f 100644 --- a/ApplicationServices/UNTESTED/LibraryCommands.cs +++ b/ApplicationServices/UNTESTED/LibraryCommands.cs @@ -12,14 +12,14 @@ namespace ApplicationServices { public static class LibraryCommands { - public static async Task<(int totalCount, int newCount)> ImportAccountAsync(ILoginCallback callback, params Account[] accounts) + public static async Task<(int totalCount, int newCount)> ImportAccountAsync(Func loginCallbackFactoryFunc, params Account[] accounts) { if (accounts is null || accounts.Length == 0) return (0, 0); try { - var importItems = await scanAccountsAsync(callback, accounts); + var importItems = await scanAccountsAsync(loginCallbackFactoryFunc, accounts); var totalCount = importItems.Count; Log.Logger.Information($"GetAllLibraryItems: Total count {totalCount}"); @@ -39,11 +39,13 @@ namespace ApplicationServices } } - private static async Task> scanAccountsAsync(ILoginCallback callback, Account[] accounts) + private static async Task> scanAccountsAsync(Func loginCallbackFactoryFunc, Account[] accounts) { var tasks = new List>>(); foreach (var account in accounts) { + var callback = loginCallbackFactoryFunc(account); + // get APIs in serial, esp b/c of logins var api = await AudibleApiActions.GetApiAsync(callback, account); diff --git a/InternalUtilities/Account.cs b/InternalUtilities/Account.cs index e1afc9ab..42a2706c 100644 --- a/InternalUtilities/Account.cs +++ b/InternalUtilities/Account.cs @@ -88,8 +88,7 @@ namespace InternalUtilities public Account(string accountId) { - ArgumentValidator.EnsureNotNullOrWhiteSpace(accountId, nameof(accountId)); - AccountId = accountId.Trim(); + AccountId = ArgumentValidator.EnsureNotNullOrWhiteSpace(accountId, nameof(accountId)).Trim(); } public override string ToString() => $"{AccountId} - {Locale?.Name ?? "[empty]"}"; diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj index 19f5cc0a..650c11b5 100644 --- a/LibationLauncher/LibationLauncher.csproj +++ b/LibationLauncher/LibationLauncher.csproj @@ -13,7 +13,7 @@ win-x64 - 3.1.12.311 + 3.1.12.315 diff --git a/LibationWinForms/UNTESTED/Dialogs/IndexLibraryDialog.cs b/LibationWinForms/UNTESTED/Dialogs/IndexLibraryDialog.cs index 548094f6..ca843515 100644 --- a/LibationWinForms/UNTESTED/Dialogs/IndexLibraryDialog.cs +++ b/LibationWinForms/UNTESTED/Dialogs/IndexLibraryDialog.cs @@ -31,7 +31,7 @@ namespace LibationWinForms.Dialogs try { - (TotalBooksProcessed, NewBooksAdded) = await LibraryCommands.ImportAccountAsync(new WinformResponder(), _accounts); + (TotalBooksProcessed, NewBooksAdded) = await LibraryCommands.ImportAccountAsync((account) => new WinformResponder(account), _accounts); } catch { diff --git a/LibationWinForms/UNTESTED/Dialogs/Login/WinformResponder.cs b/LibationWinForms/UNTESTED/Dialogs/Login/WinformResponder.cs index 27b3fed0..7a368006 100644 --- a/LibationWinForms/UNTESTED/Dialogs/Login/WinformResponder.cs +++ b/LibationWinForms/UNTESTED/Dialogs/Login/WinformResponder.cs @@ -1,10 +1,19 @@ using System; +using AudibleApi; +using InternalUtilities; using LibationWinForms.Dialogs.Login; namespace LibationWinForms.Login { - public class WinformResponder : AudibleApi.ILoginCallback + public class WinformResponder : ILoginCallback { + private Account _account { get; } + + public WinformResponder(Account account) + { + _account = Dinah.Core.ArgumentValidator.EnsureNotNull(account, nameof(account)); + } + public string Get2faCode() { using var dialog = new _2faCodeDialog();