Skip to content

Commit

Permalink
fix: correct the calculation of the number of rows with differences f…
Browse files Browse the repository at this point in the history
…or a summary tab (#555)

Fixes #554
  • Loading branch information
chrispcampbell authored Oct 16, 2024
1 parent d513284 commit dda4d69
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,10 @@ export class ComparisonsByItemSummaryViewModel {
public readonly withDiffs?: ComparisonSummarySectionViewModel,
public readonly withoutDiffs?: ComparisonSummarySectionViewModel
) {
// Create an array that holds all regular rows and determine the number
// of rows with differences
let rowsWithDiffs = 0
// Create an array that holds all regular rows
const regularRows: ComparisonSummaryRowViewModel[] = []
const addRows = (section?: ComparisonSummarySectionViewModel) => {
if (section?.rows.length > 0) {
rowsWithDiffs += section.rows.length
regularRows.push(...section.rows)
}
}
Expand All @@ -68,9 +65,12 @@ export class ComparisonsByItemSummaryViewModel {
addRows(onlyInRight)
addRows(withDiffs)
addRows(withoutDiffs)
this.rowsWithDiffs = rowsWithDiffs
this.regularRows = regularRows

// Determine the number of rows with differences
const rowsWithoutDiffsCount = withoutDiffs?.rows.length || 0
this.rowsWithDiffs = regularRows.length - rowsWithoutDiffsCount

// Derive the pinned row view models from the pinned item state
this.pinnedRows = derived(pinnedItemState.orderedKeys, $orderedKeys => {
const pinnedRows: ComparisonSummaryRowViewModel[] = []
Expand Down

0 comments on commit dda4d69

Please sign in to comment.