mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-11-30 02:01:03 +01:00
The accounts grid gains a Marketplaces button per row, enabled once the account has credentials to check with, and a dialog that asks each marketplace what it holds and lets the user tick the ones to scan. The scan picker now lists every marketplace an account reads, since one checkbox there can scan several. A marketplace that could not be reached is reported as unchecked rather than empty. Calling it empty would recreate the exact silence this feature exists to break: titles present, and nothing anywhere in the app to suggest it. Co-authored-by: rmcrackan <rmcrackan@gmail.com>
58 lines
1.5 KiB
C#
58 lines
1.5 KiB
C#
using AudibleUtilities;
|
|
using Avalonia.Collections;
|
|
using LibationUiBase;
|
|
using LibationUiBase.Forms;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LibationAvalonia.Dialogs;
|
|
|
|
public partial class ScanAccountsDialog : DialogWindow
|
|
{
|
|
public IEnumerable<Account> CheckedAccounts => Accounts.Where(a => a.IsChecked).Select(a => a.Account);
|
|
public AvaloniaList<ListItem> Accounts { get; } = new();
|
|
public class ListItem
|
|
{
|
|
public ListItem(Account account)
|
|
{
|
|
Account = account;
|
|
IsChecked = account.LibraryScan;
|
|
// lists every marketplace: one checkbox here can scan more than one
|
|
Text = MarketplacesUi.ScanPickerText(account);
|
|
}
|
|
public Account Account { get; }
|
|
public string Text { get; }
|
|
public bool IsChecked { get; set; }
|
|
public override string ToString() => Text;
|
|
}
|
|
|
|
public ScanAccountsDialog()
|
|
{
|
|
InitializeComponent();
|
|
ControlToFocusOnShow = ImportButton;
|
|
DataContext = this;
|
|
LoadAccounts();
|
|
}
|
|
|
|
private void LoadAccounts()
|
|
{
|
|
Accounts.Clear();
|
|
using var persister = AudibleApiStorage.GetAccountsSettingsPersister();
|
|
var accounts = persister.AccountsSettings.Accounts;
|
|
Accounts.AddRange(accounts.Select(account => new ListItem(account)));
|
|
}
|
|
|
|
public async Task EditAccountsAsync()
|
|
{
|
|
if (await new AccountsDialog().ShowDialog<DialogResult>(this) == DialogResult.OK)
|
|
{
|
|
// reload grid and default checkboxes
|
|
LoadAccounts();
|
|
}
|
|
}
|
|
|
|
public new void SaveAndClose()
|
|
=> base.SaveAndClose();
|
|
}
|