Files
quiver-launcher/ViewModels/CatalogViewModel.cs
T
Thomas GeorgiadisandCursor 7b674a9d08 Rebrand to Quiver 2.0.0 with in-repo Core and expanded catalog features.
Rename GithubLauncher to Quiver, vendor Quiver.Core into the main repository, add community catalog support, tests, and updated branding assets for the 2.0 release.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-20 17:38:48 +10:00

50 lines
1.6 KiB
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 bool IsAlreadySubscribed(AppSettings settings, CommunityCatalogListEntry entry) =>
settings.AppCatalogSources.Any(s =>
(!string.IsNullOrWhiteSpace(entry.Id) &&
string.Equals(s.CommunityListId, entry.Id, StringComparison.OrdinalIgnoreCase)) ||
string.Equals(s.Location, entry.Location, StringComparison.OrdinalIgnoreCase));
public AppCatalogSource CreateSourceFromCommunityEntry(CommunityCatalogListEntry entry) =>
new()
{
Name = string.IsNullOrWhiteSpace(entry.Name) ? entry.Id : entry.Name,
Location = entry.Location,
CommunityListId = entry.Id,
Enabled = true,
};
public AppCatalogSource CreateSource(string name, string location) =>
new()
{
Name = name,
Location = location,
Enabled = true,
LastFetchedUtc = DateTime.UtcNow,
LastError = null,
};
}