mirror of
https://github.com/tgeorgiadis/quiver-launcher.git
synced 2026-11-27 07:39:42 -05:00
35 lines
942 B
C#
35 lines
942 B
C#
using System.Collections.ObjectModel;
|
|
using Quiver.Models;
|
|
using Quiver.Services;
|
|
|
|
namespace Quiver.ViewModels;
|
|
|
|
public class CatalogViewModel
|
|
{
|
|
public IReadOnlyList<CatalogSourceListItem> BuildSourceListItems(AppSettings settings)
|
|
{
|
|
settings.EnsureInitialized();
|
|
return settings.AppCatalogSources
|
|
.Select(CatalogSourceListItem.FromSource)
|
|
.ToList();
|
|
}
|
|
|
|
public void RefreshSourceList(ObservableCollection<CatalogSourceListItem> target, AppSettings settings)
|
|
{
|
|
var items = BuildSourceListItems(settings);
|
|
target.Clear();
|
|
foreach (var item in items)
|
|
target.Add(item);
|
|
}
|
|
|
|
public AppCatalogSource CreateSource(string name, string location) =>
|
|
new()
|
|
{
|
|
Name = name,
|
|
Location = location,
|
|
Enabled = true,
|
|
LastFetchedUtc = DateTime.UtcNow,
|
|
LastError = null,
|
|
};
|
|
}
|