mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-04 09:13:08 +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) => {
|
return Array.from(branchSet).map((branch) => {
|
||||||
const cardCount = branchCardCounts?.[branch];
|
const cardCount = branchCardCounts?.[branch];
|
||||||
// Show card count if available, otherwise show "default" for main branch only
|
// Show card count if available, otherwise show "default" for main branch only
|
||||||
const badge = cardCount !== undefined
|
const badge = branchCardCounts !== undefined
|
||||||
? String(cardCount)
|
? String(cardCount ?? 0)
|
||||||
: branch === "main"
|
: branch === "main"
|
||||||
? "default"
|
? "default"
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|||||||
@@ -272,17 +272,13 @@ export function BoardView() {
|
|||||||
|
|
||||||
// Calculate unarchived card counts per branch
|
// Calculate unarchived card counts per branch
|
||||||
const branchCardCounts = useMemo(() => {
|
const branchCardCounts = useMemo(() => {
|
||||||
const counts: Record<string, number> = {};
|
return hookFeatures.reduce((counts, feature) => {
|
||||||
|
|
||||||
// Count unarchived features (status !== "completed") per branch
|
|
||||||
hookFeatures.forEach((feature) => {
|
|
||||||
if (feature.status !== "completed") {
|
if (feature.status !== "completed") {
|
||||||
const branch = feature.branchName || "main";
|
const branch = feature.branchName ?? "main";
|
||||||
counts[branch] = (counts[branch] || 0) + 1;
|
counts[branch] = (counts[branch] || 0) + 1;
|
||||||
}
|
}
|
||||||
});
|
return counts;
|
||||||
|
}, {} as Record<string, number>);
|
||||||
return counts;
|
|
||||||
}, [hookFeatures]);
|
}, [hookFeatures]);
|
||||||
|
|
||||||
// Custom collision detection that prioritizes columns over cards
|
// Custom collision detection that prioritizes columns over cards
|
||||||
|
|||||||
Reference in New Issue
Block a user