mirror of
https://github.com/tgeorgiadis/quiver-launcher.git
synced 2026-11-22 21:50:52 -05:00
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>
50 lines
1.6 KiB
C#
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,
|
|
};
|
|
}
|