diff --git a/InternalUtilities/UNTESTED/AudibleApiActions.cs b/InternalUtilities/UNTESTED/AudibleApiActions.cs index 320da08a..ab444787 100644 --- a/InternalUtilities/UNTESTED/AudibleApiActions.cs +++ b/InternalUtilities/UNTESTED/AudibleApiActions.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Threading.Tasks; using AudibleApi; using AudibleApiDTOs; -using FileManager; using Polly; using Polly.Retry; @@ -41,6 +40,7 @@ namespace InternalUtilities // i don't want to incur the cost of making a full dummy call every time because it fails sometimes return policy.ExecuteAsync(() => getItemsAsync(account, callback)); } + private static async Task> getItemsAsync(Account account, ILoginCallback callback) { var api = await GetApiAsync(account, callback); diff --git a/InternalUtilities/UNTESTED/AudibleApiStorage.cs b/InternalUtilities/UNTESTED/AudibleApiStorage.cs index c871d66a..46ee170d 100644 --- a/InternalUtilities/UNTESTED/AudibleApiStorage.cs +++ b/InternalUtilities/UNTESTED/AudibleApiStorage.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using System.Linq; using FileManager; using Newtonsoft.Json; @@ -29,17 +28,20 @@ namespace InternalUtilities return $"$.Accounts[?(@.AccountId == '{usernameSanitized}' && @.IdentityTokens.LocaleName == '{localeNameSanitized}')].IdentityTokens"; } - // SubString algo is better than .Trim("\"") - // orig string " - // json string "\"" - // Eg: - // => str.Trim("\"") - // output \ - // vs - // => str.Substring(1, str.Length - 2) - // output \" - // also works with surrounding single quotes private static string trimSurroundingQuotes(string str) - => str.Substring(1, str.Length - 2); + { + // SubString algo is better than .Trim("\"") + // orig string " + // json string "\"" + // Eg: + // => str.Trim("\"") + // output \ + // vs + // => str.Substring(1, str.Length - 2) + // output \" + // also works with surrounding single quotes + + return str.Substring(1, str.Length - 2); + } } } diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj index 6752c348..9068f689 100644 --- a/LibationLauncher/LibationLauncher.csproj +++ b/LibationLauncher/LibationLauncher.csproj @@ -13,7 +13,7 @@ win-x64 - 3.1.12.292 + 3.1.12.299 diff --git a/LibationWinForms/UNTESTED/Form1.Designer.cs b/LibationWinForms/UNTESTED/Form1.Designer.cs index a337e9d2..71b735dc 100644 --- a/LibationWinForms/UNTESTED/Form1.Designer.cs +++ b/LibationWinForms/UNTESTED/Form1.Designer.cs @@ -36,6 +36,8 @@ this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.importToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.scanLibraryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.scanLibraryOfAllAccountsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.scanLibraryOfSomeAccountsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.liberateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.beginBookBackupsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.beginPdfBackupsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -53,8 +55,7 @@ this.backupsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel(); this.pdfsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel(); this.addFilterBtn = new System.Windows.Forms.Button(); - this.scanLibraryOfAllAccountsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.scanLibraryOfSomeAccountsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.noAccountsYetAddAccountToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); @@ -116,8 +117,9 @@ // importToolStripMenuItem // this.importToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.noAccountsYetAddAccountToolStripMenuItem, this.scanLibraryToolStripMenuItem, - this.scanLibraryOfAllAccountsToolStripMenuItem, + this.scanLibraryOfAllAccountsToolStripMenuItem, this.scanLibraryOfSomeAccountsToolStripMenuItem}); this.importToolStripMenuItem.Name = "importToolStripMenuItem"; this.importToolStripMenuItem.Size = new System.Drawing.Size(55, 20); @@ -130,6 +132,20 @@ this.scanLibraryToolStripMenuItem.Text = "Scan &Library"; this.scanLibraryToolStripMenuItem.Click += new System.EventHandler(this.scanLibraryToolStripMenuItem_Click); // + // scanLibraryOfAllAccountsToolStripMenuItem + // + this.scanLibraryOfAllAccountsToolStripMenuItem.Name = "scanLibraryOfAllAccountsToolStripMenuItem"; + this.scanLibraryOfAllAccountsToolStripMenuItem.Size = new System.Drawing.Size(247, 22); + this.scanLibraryOfAllAccountsToolStripMenuItem.Text = "Scan Library of &All Accounts"; + this.scanLibraryOfAllAccountsToolStripMenuItem.Click += new System.EventHandler(this.scanLibraryOfAllAccountsToolStripMenuItem_Click); + // + // scanLibraryOfSomeAccountsToolStripMenuItem + // + this.scanLibraryOfSomeAccountsToolStripMenuItem.Name = "scanLibraryOfSomeAccountsToolStripMenuItem"; + this.scanLibraryOfSomeAccountsToolStripMenuItem.Size = new System.Drawing.Size(247, 22); + this.scanLibraryOfSomeAccountsToolStripMenuItem.Text = "Scan Library of &Some Accounts..."; + this.scanLibraryOfSomeAccountsToolStripMenuItem.Click += new System.EventHandler(this.scanLibraryOfSomeAccountsToolStripMenuItem_Click); + // // liberateToolStripMenuItem // this.liberateToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -260,19 +276,12 @@ this.addFilterBtn.UseVisualStyleBackColor = true; this.addFilterBtn.Click += new System.EventHandler(this.AddFilterBtn_Click); // - // scanLibraryOfAllAccountsToolStripMenuItem + // noAccountsYetAddAccountToolStripMenuItem // - this.scanLibraryOfAllAccountsToolStripMenuItem.Name = "scanLibraryOfAllAccountsToolStripMenuItem"; - this.scanLibraryOfAllAccountsToolStripMenuItem.Size = new System.Drawing.Size(247, 22); - this.scanLibraryOfAllAccountsToolStripMenuItem.Text = "Scan Library of &All Accounts"; - this.scanLibraryOfAllAccountsToolStripMenuItem.Click += new System.EventHandler(this.scanLibraryOfAllAccountsToolStripMenuItem_Click); - // - // scanLibraryOfSomeAccountsToolStripMenuItem - // - this.scanLibraryOfSomeAccountsToolStripMenuItem.Name = "scanLibraryOfSomeAccountsToolStripMenuItem"; - this.scanLibraryOfSomeAccountsToolStripMenuItem.Size = new System.Drawing.Size(247, 22); - this.scanLibraryOfSomeAccountsToolStripMenuItem.Text = "Scan Library of &Some Accounts..."; - this.scanLibraryOfSomeAccountsToolStripMenuItem.Click += new System.EventHandler(this.scanLibraryOfSomeAccountsToolStripMenuItem_Click); + this.noAccountsYetAddAccountToolStripMenuItem.Name = "noAccountsYetAddAccountToolStripMenuItem"; + this.noAccountsYetAddAccountToolStripMenuItem.Size = new System.Drawing.Size(247, 22); + this.noAccountsYetAddAccountToolStripMenuItem.Text = "No accounts yet. A&dd Account..."; + this.noAccountsYetAddAccountToolStripMenuItem.Click += new System.EventHandler(this.noAccountsYetAddAccountToolStripMenuItem_Click); // // Form1 // @@ -328,5 +337,6 @@ private System.Windows.Forms.ToolStripMenuItem accountsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem scanLibraryOfAllAccountsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem scanLibraryOfSomeAccountsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem noAccountsYetAddAccountToolStripMenuItem; } } diff --git a/LibationWinForms/UNTESTED/Form1.cs b/LibationWinForms/UNTESTED/Form1.cs index b4c17068..d1907ebc 100644 --- a/LibationWinForms/UNTESTED/Form1.cs +++ b/LibationWinForms/UNTESTED/Form1.cs @@ -231,11 +231,18 @@ namespace LibationWinForms #region Import menu private void setImportMenu() { - var hasMultipleAccounts = AudibleApiStorage.GetPersistentAccountsSettings().Accounts.Count > 1; + var count = AudibleApiStorage.GetPersistentAccountsSettings().Accounts.Count; - scanLibraryToolStripMenuItem.Visible = !hasMultipleAccounts; - scanLibraryOfAllAccountsToolStripMenuItem.Visible = hasMultipleAccounts; - scanLibraryOfSomeAccountsToolStripMenuItem.Visible = hasMultipleAccounts; + noAccountsYetAddAccountToolStripMenuItem.Visible = count == 0; + scanLibraryToolStripMenuItem.Visible = count == 1; + scanLibraryOfAllAccountsToolStripMenuItem.Visible = count > 1; + scanLibraryOfSomeAccountsToolStripMenuItem.Visible = count > 1; + } + + private void noAccountsYetAddAccountToolStripMenuItem_Click(object sender, EventArgs e) + { + MessageBox.Show("To load your Audible library, come back here to the Import menu after adding your account"); + accountsToolStripMenuItem_Click(sender, e); } private void scanLibraryToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/WinFormsDesigner/Form1.Designer.cs b/WinFormsDesigner/Form1.Designer.cs index c6a4a70c..b32f5df5 100644 --- a/WinFormsDesigner/Form1.Designer.cs +++ b/WinFormsDesigner/Form1.Designer.cs @@ -36,6 +36,8 @@ this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.importToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.scanLibraryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.scanLibraryOfAllAccountsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.scanLibraryOfSomeAccountsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.liberateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.beginBookBackupsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.beginPdfBackupsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -53,8 +55,7 @@ this.backupsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel(); this.pdfsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel(); this.addFilterBtn = new System.Windows.Forms.Button(); - this.scanLibraryOfAllAccountsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.scanLibraryOfSomeAccountsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.noAccountsYetAddAccountToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); @@ -113,6 +114,7 @@ // importToolStripMenuItem // this.importToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.noAccountsYetAddAccountToolStripMenuItem, this.scanLibraryToolStripMenuItem, this.scanLibraryOfAllAccountsToolStripMenuItem, this.scanLibraryOfSomeAccountsToolStripMenuItem}); @@ -126,6 +128,18 @@ this.scanLibraryToolStripMenuItem.Size = new System.Drawing.Size(247, 22); this.scanLibraryToolStripMenuItem.Text = "Scan &Library"; // + // scanLibraryOfAllAccountsToolStripMenuItem + // + this.scanLibraryOfAllAccountsToolStripMenuItem.Name = "scanLibraryOfAllAccountsToolStripMenuItem"; + this.scanLibraryOfAllAccountsToolStripMenuItem.Size = new System.Drawing.Size(247, 22); + this.scanLibraryOfAllAccountsToolStripMenuItem.Text = "Scan Library of &All Accounts"; + // + // scanLibraryOfSomeAccountsToolStripMenuItem + // + this.scanLibraryOfSomeAccountsToolStripMenuItem.Name = "scanLibraryOfSomeAccountsToolStripMenuItem"; + this.scanLibraryOfSomeAccountsToolStripMenuItem.Size = new System.Drawing.Size(247, 22); + this.scanLibraryOfSomeAccountsToolStripMenuItem.Text = "Scan Library of &Some Accounts..."; + // // liberateToolStripMenuItem // this.liberateToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -248,17 +262,11 @@ this.addFilterBtn.Text = "Add To Quick Filters"; this.addFilterBtn.UseVisualStyleBackColor = true; // - // scanLibraryOfAllAccountsToolStripMenuItem + // noAccountsYetAddAccountToolStripMenuItem // - this.scanLibraryOfAllAccountsToolStripMenuItem.Name = "scanLibraryOfAllAccountsToolStripMenuItem"; - this.scanLibraryOfAllAccountsToolStripMenuItem.Size = new System.Drawing.Size(247, 22); - this.scanLibraryOfAllAccountsToolStripMenuItem.Text = "Scan Library of &All Accounts"; - // - // scanLibraryOfSomeAccountsToolStripMenuItem - // - this.scanLibraryOfSomeAccountsToolStripMenuItem.Name = "scanLibraryOfSomeAccountsToolStripMenuItem"; - this.scanLibraryOfSomeAccountsToolStripMenuItem.Size = new System.Drawing.Size(247, 22); - this.scanLibraryOfSomeAccountsToolStripMenuItem.Text = "Scan Library of &Some Accounts..."; + this.noAccountsYetAddAccountToolStripMenuItem.Name = "noAccountsYetAddAccountToolStripMenuItem"; + this.noAccountsYetAddAccountToolStripMenuItem.Size = new System.Drawing.Size(247, 22); + this.noAccountsYetAddAccountToolStripMenuItem.Text = "No accounts yet. A&dd Account..."; // // Form1 // @@ -313,5 +321,6 @@ private System.Windows.Forms.ToolStripMenuItem accountsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem scanLibraryOfAllAccountsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem scanLibraryOfSomeAccountsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem noAccountsYetAddAccountToolStripMenuItem; } }