If no accounts, Import>Scan Library to prompt user to create account
This commit is contained in:
parent
81b6833118
commit
0025825d5c
@ -4,7 +4,6 @@ using System.Linq;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AudibleApi;
|
using AudibleApi;
|
||||||
using AudibleApiDTOs;
|
using AudibleApiDTOs;
|
||||||
using FileManager;
|
|
||||||
using Polly;
|
using Polly;
|
||||||
using Polly.Retry;
|
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
|
// 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));
|
return policy.ExecuteAsync(() => getItemsAsync(account, callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<List<Item>> getItemsAsync(Account account, ILoginCallback callback)
|
private static async Task<List<Item>> getItemsAsync(Account account, ILoginCallback callback)
|
||||||
{
|
{
|
||||||
var api = await GetApiAsync(account, callback);
|
var api = await GetApiAsync(account, callback);
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using FileManager;
|
using FileManager;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
@ -29,17 +28,20 @@ namespace InternalUtilities
|
|||||||
|
|
||||||
return $"$.Accounts[?(@.AccountId == '{usernameSanitized}' && @.IdentityTokens.LocaleName == '{localeNameSanitized}')].IdentityTokens";
|
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)
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
|
||||||
<Version>3.1.12.292</Version>
|
<Version>3.1.12.299</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
40
LibationWinForms/UNTESTED/Form1.Designer.cs
generated
40
LibationWinForms/UNTESTED/Form1.Designer.cs
generated
@ -36,6 +36,8 @@
|
|||||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||||
this.importToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.importToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.scanLibraryToolStripMenuItem = 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.liberateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.beginBookBackupsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.beginBookBackupsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.beginPdfBackupsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.beginPdfBackupsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
@ -53,8 +55,7 @@
|
|||||||
this.backupsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel();
|
this.backupsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
this.pdfsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel();
|
this.pdfsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
this.addFilterBtn = new System.Windows.Forms.Button();
|
this.addFilterBtn = new System.Windows.Forms.Button();
|
||||||
this.scanLibraryOfAllAccountsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.noAccountsYetAddAccountToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.scanLibraryOfSomeAccountsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.menuStrip1.SuspendLayout();
|
this.menuStrip1.SuspendLayout();
|
||||||
this.statusStrip1.SuspendLayout();
|
this.statusStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -116,8 +117,9 @@
|
|||||||
// importToolStripMenuItem
|
// importToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.importToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.importToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.noAccountsYetAddAccountToolStripMenuItem,
|
||||||
this.scanLibraryToolStripMenuItem,
|
this.scanLibraryToolStripMenuItem,
|
||||||
this.scanLibraryOfAllAccountsToolStripMenuItem,
|
this.scanLibraryOfAllAccountsToolStripMenuItem,
|
||||||
this.scanLibraryOfSomeAccountsToolStripMenuItem});
|
this.scanLibraryOfSomeAccountsToolStripMenuItem});
|
||||||
this.importToolStripMenuItem.Name = "importToolStripMenuItem";
|
this.importToolStripMenuItem.Name = "importToolStripMenuItem";
|
||||||
this.importToolStripMenuItem.Size = new System.Drawing.Size(55, 20);
|
this.importToolStripMenuItem.Size = new System.Drawing.Size(55, 20);
|
||||||
@ -130,6 +132,20 @@
|
|||||||
this.scanLibraryToolStripMenuItem.Text = "Scan &Library";
|
this.scanLibraryToolStripMenuItem.Text = "Scan &Library";
|
||||||
this.scanLibraryToolStripMenuItem.Click += new System.EventHandler(this.scanLibraryToolStripMenuItem_Click);
|
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
|
// liberateToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.liberateToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.liberateToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
@ -260,19 +276,12 @@
|
|||||||
this.addFilterBtn.UseVisualStyleBackColor = true;
|
this.addFilterBtn.UseVisualStyleBackColor = true;
|
||||||
this.addFilterBtn.Click += new System.EventHandler(this.AddFilterBtn_Click);
|
this.addFilterBtn.Click += new System.EventHandler(this.AddFilterBtn_Click);
|
||||||
//
|
//
|
||||||
// scanLibraryOfAllAccountsToolStripMenuItem
|
// noAccountsYetAddAccountToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.scanLibraryOfAllAccountsToolStripMenuItem.Name = "scanLibraryOfAllAccountsToolStripMenuItem";
|
this.noAccountsYetAddAccountToolStripMenuItem.Name = "noAccountsYetAddAccountToolStripMenuItem";
|
||||||
this.scanLibraryOfAllAccountsToolStripMenuItem.Size = new System.Drawing.Size(247, 22);
|
this.noAccountsYetAddAccountToolStripMenuItem.Size = new System.Drawing.Size(247, 22);
|
||||||
this.scanLibraryOfAllAccountsToolStripMenuItem.Text = "Scan Library of &All Accounts";
|
this.noAccountsYetAddAccountToolStripMenuItem.Text = "No accounts yet. A&dd Account...";
|
||||||
this.scanLibraryOfAllAccountsToolStripMenuItem.Click += new System.EventHandler(this.scanLibraryOfAllAccountsToolStripMenuItem_Click);
|
this.noAccountsYetAddAccountToolStripMenuItem.Click += new System.EventHandler(this.noAccountsYetAddAccountToolStripMenuItem_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);
|
|
||||||
//
|
//
|
||||||
// Form1
|
// Form1
|
||||||
//
|
//
|
||||||
@ -328,5 +337,6 @@
|
|||||||
private System.Windows.Forms.ToolStripMenuItem accountsToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem accountsToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem scanLibraryOfAllAccountsToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem scanLibraryOfAllAccountsToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem scanLibraryOfSomeAccountsToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem scanLibraryOfSomeAccountsToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem noAccountsYetAddAccountToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -231,11 +231,18 @@ namespace LibationWinForms
|
|||||||
#region Import menu
|
#region Import menu
|
||||||
private void setImportMenu()
|
private void setImportMenu()
|
||||||
{
|
{
|
||||||
var hasMultipleAccounts = AudibleApiStorage.GetPersistentAccountsSettings().Accounts.Count > 1;
|
var count = AudibleApiStorage.GetPersistentAccountsSettings().Accounts.Count;
|
||||||
|
|
||||||
scanLibraryToolStripMenuItem.Visible = !hasMultipleAccounts;
|
noAccountsYetAddAccountToolStripMenuItem.Visible = count == 0;
|
||||||
scanLibraryOfAllAccountsToolStripMenuItem.Visible = hasMultipleAccounts;
|
scanLibraryToolStripMenuItem.Visible = count == 1;
|
||||||
scanLibraryOfSomeAccountsToolStripMenuItem.Visible = hasMultipleAccounts;
|
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)
|
private void scanLibraryToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
|||||||
33
WinFormsDesigner/Form1.Designer.cs
generated
33
WinFormsDesigner/Form1.Designer.cs
generated
@ -36,6 +36,8 @@
|
|||||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||||
this.importToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.importToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.scanLibraryToolStripMenuItem = 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.liberateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.beginBookBackupsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.beginBookBackupsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.beginPdfBackupsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.beginPdfBackupsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
@ -53,8 +55,7 @@
|
|||||||
this.backupsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel();
|
this.backupsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
this.pdfsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel();
|
this.pdfsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
this.addFilterBtn = new System.Windows.Forms.Button();
|
this.addFilterBtn = new System.Windows.Forms.Button();
|
||||||
this.scanLibraryOfAllAccountsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.noAccountsYetAddAccountToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.scanLibraryOfSomeAccountsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.menuStrip1.SuspendLayout();
|
this.menuStrip1.SuspendLayout();
|
||||||
this.statusStrip1.SuspendLayout();
|
this.statusStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -113,6 +114,7 @@
|
|||||||
// importToolStripMenuItem
|
// importToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.importToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.importToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.noAccountsYetAddAccountToolStripMenuItem,
|
||||||
this.scanLibraryToolStripMenuItem,
|
this.scanLibraryToolStripMenuItem,
|
||||||
this.scanLibraryOfAllAccountsToolStripMenuItem,
|
this.scanLibraryOfAllAccountsToolStripMenuItem,
|
||||||
this.scanLibraryOfSomeAccountsToolStripMenuItem});
|
this.scanLibraryOfSomeAccountsToolStripMenuItem});
|
||||||
@ -126,6 +128,18 @@
|
|||||||
this.scanLibraryToolStripMenuItem.Size = new System.Drawing.Size(247, 22);
|
this.scanLibraryToolStripMenuItem.Size = new System.Drawing.Size(247, 22);
|
||||||
this.scanLibraryToolStripMenuItem.Text = "Scan &Library";
|
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
|
// liberateToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.liberateToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.liberateToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
@ -248,17 +262,11 @@
|
|||||||
this.addFilterBtn.Text = "Add To Quick Filters";
|
this.addFilterBtn.Text = "Add To Quick Filters";
|
||||||
this.addFilterBtn.UseVisualStyleBackColor = true;
|
this.addFilterBtn.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// scanLibraryOfAllAccountsToolStripMenuItem
|
// noAccountsYetAddAccountToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.scanLibraryOfAllAccountsToolStripMenuItem.Name = "scanLibraryOfAllAccountsToolStripMenuItem";
|
this.noAccountsYetAddAccountToolStripMenuItem.Name = "noAccountsYetAddAccountToolStripMenuItem";
|
||||||
this.scanLibraryOfAllAccountsToolStripMenuItem.Size = new System.Drawing.Size(247, 22);
|
this.noAccountsYetAddAccountToolStripMenuItem.Size = new System.Drawing.Size(247, 22);
|
||||||
this.scanLibraryOfAllAccountsToolStripMenuItem.Text = "Scan Library of &All Accounts";
|
this.noAccountsYetAddAccountToolStripMenuItem.Text = "No accounts yet. A&dd Account...";
|
||||||
//
|
|
||||||
// scanLibraryOfSomeAccountsToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.scanLibraryOfSomeAccountsToolStripMenuItem.Name = "scanLibraryOfSomeAccountsToolStripMenuItem";
|
|
||||||
this.scanLibraryOfSomeAccountsToolStripMenuItem.Size = new System.Drawing.Size(247, 22);
|
|
||||||
this.scanLibraryOfSomeAccountsToolStripMenuItem.Text = "Scan Library of &Some Accounts...";
|
|
||||||
//
|
//
|
||||||
// Form1
|
// Form1
|
||||||
//
|
//
|
||||||
@ -313,5 +321,6 @@
|
|||||||
private System.Windows.Forms.ToolStripMenuItem accountsToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem accountsToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem scanLibraryOfAllAccountsToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem scanLibraryOfAllAccountsToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem scanLibraryOfSomeAccountsToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem scanLibraryOfSomeAccountsToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem noAccountsYetAddAccountToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user