central event for library altered: books added or removed
This commit is contained in:
parent
9e0caf34d6
commit
c2c732b2b1
4 changed files with 28 additions and 24 deletions
|
|
@ -15,8 +15,6 @@ namespace LibationWinForms.Dialogs
|
|||
{
|
||||
public partial class RemoveBooksDialog : Form
|
||||
{
|
||||
public bool BooksRemoved { get; private set; }
|
||||
|
||||
private Account[] _accounts { get; }
|
||||
private readonly List<LibraryBook> _libraryBooks;
|
||||
private readonly SortableBindingList<RemovableGridEntry> _removableGridEntries;
|
||||
|
|
@ -83,7 +81,7 @@ namespace LibationWinForms.Dialogs
|
|||
}
|
||||
}
|
||||
|
||||
private void btnRemoveBooks_Click(object sender, EventArgs e)
|
||||
private async void btnRemoveBooks_Click(object sender, EventArgs e)
|
||||
{
|
||||
var selectedBooks = SelectedEntries.ToList();
|
||||
|
||||
|
|
@ -105,13 +103,11 @@ namespace LibationWinForms.Dialogs
|
|||
if (result == DialogResult.Yes)
|
||||
{
|
||||
var idsToRemove = selectedBooks.Select(rge => rge.AudibleProductId).ToList();
|
||||
var removeLibraryBooks = LibraryCommands.RemoveBooks(idsToRemove);
|
||||
var removeLibraryBooks = await LibraryCommands.RemoveBooksAsync(idsToRemove);
|
||||
|
||||
foreach (var rEntry in selectedBooks)
|
||||
_removableGridEntries.Remove(rEntry);
|
||||
|
||||
BooksRemoved = removeLibraryBooks.Count > 0;
|
||||
|
||||
UpdateSelection();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,9 @@ namespace LibationWinForms
|
|||
return;
|
||||
|
||||
// independent UI updates
|
||||
this.Load += (_, __) => RestoreSizeAndLocation();
|
||||
this.Load += (_, __) => RefreshImportMenu();
|
||||
this.Load += restoreSizeAndLocation;
|
||||
this.Load += RefreshImportMenu;
|
||||
LibraryCommands.LibrarySizeChanged += reloadGridAndUpdateBottomNumbers;
|
||||
LibraryCommands.BookUserDefinedItemCommitted += setBackupCounts;
|
||||
|
||||
var format = System.Drawing.Imaging.ImageFormat.Jpeg;
|
||||
|
|
@ -45,6 +46,8 @@ namespace LibationWinForms
|
|||
if (this.DesignMode)
|
||||
return;
|
||||
|
||||
// can't refactor into "this.Load => reloadGridAndUpdateBottomNumbers"
|
||||
// because loadInitialQuickFilterState must follow it
|
||||
reloadGridAndUpdateBottomNumbers();
|
||||
|
||||
// also applies filter. ONLY call AFTER loading grid
|
||||
|
|
@ -56,7 +59,7 @@ namespace LibationWinForms
|
|||
SaveSizeAndLocation();
|
||||
}
|
||||
|
||||
private void RestoreSizeAndLocation()
|
||||
private void restoreSizeAndLocation(object _ = null, object __ = null)
|
||||
{
|
||||
var config = Configuration.Instance;
|
||||
|
||||
|
|
@ -126,7 +129,7 @@ namespace LibationWinForms
|
|||
config.MainFormIsMaximized = this.WindowState == FormWindowState.Maximized;
|
||||
}
|
||||
|
||||
private void reloadGridAndUpdateBottomNumbers()
|
||||
private void reloadGridAndUpdateBottomNumbers(object _ = null, object __ = null)
|
||||
{
|
||||
// suppressed filter while init'ing UI
|
||||
var prev_isProcessingGridSelect = isProcessingGridSelect;
|
||||
|
|
@ -303,7 +306,7 @@ namespace LibationWinForms
|
|||
#endregion
|
||||
|
||||
#region Import menu
|
||||
public void RefreshImportMenu()
|
||||
public void RefreshImportMenu(object _ = null, EventArgs __ = null)
|
||||
{
|
||||
using var persister = AudibleApiStorage.GetAccountsSettingsPersister();
|
||||
var count = persister.AccountsSettings.Accounts.Count;
|
||||
|
|
@ -393,9 +396,6 @@ namespace LibationWinForms
|
|||
{
|
||||
using var dialog = new RemoveBooksDialog(accounts);
|
||||
dialog.ShowDialog();
|
||||
|
||||
if (dialog.BooksRemoved)
|
||||
reloadGridAndUpdateBottomNumbers();
|
||||
}
|
||||
|
||||
private void scanLibraries(IEnumerable<Account> accounts) => scanLibraries(accounts.ToArray());
|
||||
|
|
@ -408,9 +408,6 @@ namespace LibationWinForms
|
|||
var newAdded = dialog.NewBooksAdded;
|
||||
|
||||
MessageBox.Show($"Total processed: {totalProcessed}\r\nNew: {newAdded}");
|
||||
|
||||
if (totalProcessed > 0)
|
||||
reloadGridAndUpdateBottomNumbers();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue