feat(app): register UpdateCheckService and InstallerLocator in DI

This commit is contained in:
mika kuns
2026-04-23 15:03:28 +02:00
parent ee09706811
commit 0934b294c2
2 changed files with 22 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
using Avalonia;
using ClaudeDo.Data;
using ClaudeDo.Data.Git;
using ClaudeDo.Releases;
using ClaudeDo.Ui;
using ClaudeDo.Ui.Services;
using ClaudeDo.Ui.ViewModels;
@@ -9,6 +10,8 @@ using ClaudeDo.Ui.ViewModels.Modals;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Net.Http;
using System.Reflection;
using System.Runtime.InteropServices;
namespace ClaudeDo.App;
@@ -75,6 +78,17 @@ sealed class Program
sc.AddSingleton<GitService>();
sc.AddSingleton(sp => new WorkerClient(sp.GetRequiredService<AppSettings>().SignalRUrl));
// Release check + installer update
sc.AddSingleton<HttpClient>(_ => new HttpClient { Timeout = TimeSpan.FromSeconds(10) });
sc.AddSingleton<IReleaseClient>(sp => new ReleaseClient(sp.GetRequiredService<HttpClient>()));
sc.AddSingleton<InstallerLocator>();
sc.AddSingleton(sp =>
{
var releases = sp.GetRequiredService<IReleaseClient>();
var version = Assembly.GetEntryAssembly()?.GetName().Version?.ToString() ?? "0.0.0.0";
return new UpdateCheckService(releases, version);
});
// ViewModels
sc.AddTransient<WorktreeModalViewModel>();
sc.AddTransient<SettingsModalViewModel>();

View File

@@ -19,6 +19,9 @@ public sealed partial class IslandsShellViewModel : ViewModelBase
public bool IsOffline => !Worker.IsConnected && !Worker.IsReconnecting;
private readonly UpdateCheckService _updateCheck;
private readonly InstallerLocator _installerLocator;
[ObservableProperty]
private double _windowWidth = 1280;
@@ -47,9 +50,13 @@ public sealed partial class IslandsShellViewModel : ViewModelBase
ListsIslandViewModel lists,
TasksIslandViewModel tasks,
DetailsIslandViewModel details,
WorkerClient worker)
WorkerClient worker,
UpdateCheckService updateCheck,
InstallerLocator installerLocator)
{
Lists = lists; Tasks = tasks; Details = details; Worker = worker;
_updateCheck = updateCheck;
_installerLocator = installerLocator;
Lists.SelectionChanged += (_, _) => Tasks.LoadForList(Lists.SelectedList);
Tasks.SelectionChanged += (_, _) => Details.Bind(Tasks.SelectedTask);
Tasks.TasksChanged += (_, _) => _ = Lists.RefreshCountsAsync();