mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-30 06:12:03 +00:00
fix: address PR review comments
- Fix branch fallback logic: use nullish coalescing (??) instead of || to handle empty strings correctly (empty string represents unassigned features, not main branch) - Refactor branchCardCounts calculation: use reduce instead of forEach for better conciseness and readability - Fix badge semantics in BranchAutocomplete: check branchCardCounts !== undefined first to ensure numeric badges (including 0) only appear when actual count data exists, while 'default' is reserved for when count data is unavailable
This commit is contained in:
@@ -33,8 +33,8 @@ export function BranchAutocomplete({
|
||||
return Array.from(branchSet).map((branch) => {
|
||||
const cardCount = branchCardCounts?.[branch];
|
||||
// Show card count if available, otherwise show "default" for main branch only
|
||||
const badge = cardCount !== undefined
|
||||
? String(cardCount)
|
||||
const badge = branchCardCounts !== undefined
|
||||
? String(cardCount ?? 0)
|
||||
: branch === "main"
|
||||
? "default"
|
||||
: undefined;
|
||||
|
||||
@@ -272,17 +272,13 @@ export function BoardView() {
|
||||
|
||||
// Calculate unarchived card counts per branch
|
||||
const branchCardCounts = useMemo(() => {
|
||||
const counts: Record<string, number> = {};
|
||||
|
||||
// Count unarchived features (status !== "completed") per branch
|
||||
hookFeatures.forEach((feature) => {
|
||||
return hookFeatures.reduce((counts, feature) => {
|
||||
if (feature.status !== "completed") {
|
||||
const branch = feature.branchName || "main";
|
||||
const branch = feature.branchName ?? "main";
|
||||
counts[branch] = (counts[branch] || 0) + 1;
|
||||
}
|
||||
});
|
||||
|
||||
return counts;
|
||||
return counts;
|
||||
}, {} as Record<string, number>);
|
||||
}, [hookFeatures]);
|
||||
|
||||
// Custom collision detection that prioritizes columns over cards
|
||||
|
||||
Reference in New Issue
Block a user