refactor(ui): unify list-linked-repo predicate into RepoLinkage
ListsIslandViewModel and SettingsModalViewModel each re-implemented "does this list have a linked WorkingDir" with different whitespace handling. RepoLinkage.IsLinked/IsLinkedInDb is now the single definition; both callers derive from it, closing the whitespace-only WorkingDir gap where the Settings modal disagreed with the ListsIsland banner.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using ClaudeDo.Data.Models;
|
||||
|
||||
namespace ClaudeDo.Ui.Services;
|
||||
|
||||
// Single definition of "does this list have a linked repo" — a WorkingDir that is set to
|
||||
// something other than blank/whitespace. ListsIslandViewModel and SettingsModalViewModel each
|
||||
// answer this over a different scope (UserLists in memory vs. all Lists rows in the DB) and need
|
||||
// it in different shapes, but both must agree on what "linked" means.
|
||||
public static class RepoLinkage
|
||||
{
|
||||
public static bool IsLinked(string? workingDir) => !string.IsNullOrWhiteSpace(workingDir);
|
||||
|
||||
// EF Core can't translate string.IsNullOrWhiteSpace against Sqlite, so the DB-side check is
|
||||
// spelled out via Trim() instead — same semantics as IsLinked above.
|
||||
public static readonly Expression<Func<ListEntity, bool>> IsLinkedInDb =
|
||||
l => l.WorkingDir != null && l.WorkingDir.Trim() != "";
|
||||
}
|
||||
Reference in New Issue
Block a user