Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"permissions": {
"allow": [
"mcp__serena__list_dir",
"Bash(dotnet build:*)"
]
}
}
7 changes: 6 additions & 1 deletion src/AStar.Dev.File.App/AStar.Dev.File.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
<AvaloniaResource Include="Assets\**" />
</ItemGroup>

<ItemGroup>
<None Include="FodyWeavers.xml" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.5" />
<PackageReference Include="Serilog" Version="4.3.1" />
Expand All @@ -29,7 +33,8 @@
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.3.13" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.2" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.3.9" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
3 changes: 3 additions & 0 deletions src/AStar.Dev.File.App/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ReactiveUI />
</Weavers>
4 changes: 3 additions & 1 deletion src/AStar.Dev.File.App/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Avalonia;
using Avalonia.ReactiveUI;
using System;

namespace AStar.Dev.File.App;
Expand All @@ -17,5 +18,6 @@ public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace();
.LogToTrace()
.UseReactiveUI();
}
39 changes: 21 additions & 18 deletions src/AStar.Dev.File.App/ViewModels/DeletePendingViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
using AStar.Dev.File.App.Data;
using AStar.Dev.File.App.Services;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.EntityFrameworkCore;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reactive;
using System.Threading.Tasks;

namespace AStar.Dev.File.App.ViewModels;

public partial class DeletePendingViewModel : ViewModelBase
public class DeletePendingViewModel : ViewModelBase
{
private readonly IDbContextFactory<FileAppDbContext> _dbContextFactory;
private readonly IFileDeleteService _fileDeleteService;
private readonly IFileViewerService _fileViewerService;

[ObservableProperty]
private bool _isDeleting;

[ObservableProperty]
private int _pendingDeleteCount;

[ObservableProperty]
private string _statusMessage = string.Empty;
[Reactive] public bool IsDeleting { get; set; }
[Reactive] public int PendingDeleteCount { get; set; }
[Reactive] public string StatusMessage { get; set; } = string.Empty;

public ObservableCollection<ScannedFileDisplayItem> PendingDeleteFiles { get; } = [];

public event Action<ScannedFileDisplayItem>? ViewFileRequested;

public ReactiveCommand<ScannedFileDisplayItem?, Unit> TogglePendingDeleteCommand { get; }
public ReactiveCommand<Unit, Unit> DeleteAllCommand { get; }
public ReactiveCommand<Unit, Unit> ClearMarkingsCommand { get; }
public ReactiveCommand<ScannedFileDisplayItem?, Unit> ViewFileCommand { get; }

public DeletePendingViewModel(
IDbContextFactory<FileAppDbContext> dbContextFactory,
IFileDeleteService fileDeleteService,
Expand All @@ -39,10 +40,18 @@ public DeletePendingViewModel(
_fileViewerService = fileViewerService;
_fileViewerService.FileViewRequested += item => ViewFileRequested?.Invoke(item);

TogglePendingDeleteCommand = ReactiveCommand.CreateFromTask<ScannedFileDisplayItem?>(TogglePendingDelete);

var canDeleteAll = this.WhenAnyValue(x => x.IsDeleting, x => x.PendingDeleteCount,
(deleting, count) => !deleting && count > 0);
DeleteAllCommand = ReactiveCommand.CreateFromTask(DeleteAll, canDeleteAll);

ClearMarkingsCommand = ReactiveCommand.CreateFromTask(ClearMarkings);
ViewFileCommand = ReactiveCommand.CreateFromTask<ScannedFileDisplayItem?>(ViewFile);

_ = LoadPendingFilesAsync();
}

[RelayCommand]
private async Task TogglePendingDelete(ScannedFileDisplayItem? item)
{
if (item is null) return;
Expand All @@ -58,7 +67,6 @@ private async Task TogglePendingDelete(ScannedFileDisplayItem? item)
await LoadPendingFilesAsync();
}

[RelayCommand(CanExecute = nameof(CanDeleteAll))]
private async Task DeleteAll()
{
if (PendingDeleteFiles.Count == 0)
Expand Down Expand Up @@ -95,9 +103,6 @@ private async Task DeleteAll()
}
}

private bool CanDeleteAll() => !IsDeleting && PendingDeleteFiles.Count > 0;

[RelayCommand]
private async Task ClearMarkings()
{
if (PendingDeleteFiles.Count == 0)
Expand All @@ -116,7 +121,6 @@ private async Task ClearMarkings()
await LoadPendingFilesAsync();
}

[RelayCommand]
private async Task ViewFile(ScannedFileDisplayItem? item)
{
await _fileViewerService.ViewFileAsync(item);
Expand All @@ -137,7 +141,6 @@ private async Task LoadPendingFilesAsync()
files.ForEach(file => PendingDeleteFiles.Add(new ScannedFileDisplayItem(file)));

PendingDeleteCount = PendingDeleteFiles.Count;
DeleteAllCommand.NotifyCanExecuteChanged();
}
catch (Exception ex)
{
Expand Down
Loading
Loading