refactor(transactions): drop the new-since-last-visit counter
Keep only the per-row marking (accent border + tint); remove the count shown above the list. Also drop what that left orphaned: the countNewSince helper and its tests, and the two unused locale keys.
This commit is contained in:
parent
0cd2b9b0f7
commit
2ba1ba36fb
|
|
@ -203,9 +203,7 @@
|
|||
"8. Your Rights Under GDPR": "8. Tus Derechos Bajo GDPR",
|
||||
"9. Cookies and Tracking": "9. Cookies y Rastreo",
|
||||
"9. Disclaimers and Warranties": "9. Descargos de Responsabilidad y Garantías",
|
||||
"1 new since your last visit": "1 nueva desde tu última visita",
|
||||
":count matching transaction(s)": ":count transacción(es) coincidente(s)",
|
||||
":count new since your last visit": ":count nuevas desde tu última visita",
|
||||
":count new transactions synced on Whisper Money": ":count nuevas transacciones sincronizadas en Whisper Money",
|
||||
":count transaction": ":count transacción",
|
||||
":count transaction(s) will be affected.": ":count transacción(es) serán afectadas.",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { countNewSince, isNewSince, newestCreatedAt } from './new-transactions';
|
||||
import { isNewSince, newestCreatedAt } from './new-transactions';
|
||||
|
||||
const tx = (created_at: string) => ({ created_at });
|
||||
|
||||
|
|
@ -35,27 +35,6 @@ describe('isNewSince', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('countNewSince', () => {
|
||||
const transactions = [
|
||||
tx('2026-06-29T10:00:00Z'),
|
||||
tx('2026-06-20T08:00:00Z'), // seen, interleaved
|
||||
tx('2026-06-28T09:00:00Z'),
|
||||
tx('2026-06-19T08:00:00Z'), // seen
|
||||
];
|
||||
|
||||
it('counts every new row regardless of position', () => {
|
||||
expect(countNewSince(transactions, '2026-06-25T00:00:00Z')).toBe(2);
|
||||
});
|
||||
|
||||
it('returns 0 when nothing is new', () => {
|
||||
expect(countNewSince(transactions, '2026-06-30T00:00:00Z')).toBe(0);
|
||||
});
|
||||
|
||||
it('returns 0 on a first visit', () => {
|
||||
expect(countNewSince(transactions, null)).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('newestCreatedAt', () => {
|
||||
it('returns null for an empty list', () => {
|
||||
expect(newestCreatedAt([])).toBeNull();
|
||||
|
|
|
|||
|
|
@ -69,19 +69,3 @@ export function isNewSince(
|
|||
|
||||
return !Number.isNaN(createdMs) && createdMs > lastVisitMs;
|
||||
}
|
||||
|
||||
/**
|
||||
* How many of the given transactions arrived since the last visit. Counts only
|
||||
* the loaded transactions, so it can undercount when newer rows live in a
|
||||
* not-yet-loaded page.
|
||||
*/
|
||||
export function countNewSince(
|
||||
transactions: Pick<Transaction, 'created_at'>[],
|
||||
lastVisit: string | null,
|
||||
): number {
|
||||
return transactions.reduce(
|
||||
(count, transaction) =>
|
||||
isNewSince(transaction, lastVisit) ? count + 1 : count,
|
||||
0,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ import {
|
|||
} from '@/lib/cursor-pagination';
|
||||
import { consoleDebug } from '@/lib/debug';
|
||||
import {
|
||||
countNewSince,
|
||||
isNewSince,
|
||||
loadLastVisit,
|
||||
newestCreatedAt,
|
||||
|
|
@ -309,7 +308,10 @@ function TransactionRowComponent({
|
|||
(row.getIsSelected() || contextMenuOpen) && 'selected'
|
||||
}
|
||||
data-index={virtualRow.index}
|
||||
className={cn('cursor-pointer', isNew && 'bg-blue-500/5 dark:bg-blue-500/10')}
|
||||
className={cn(
|
||||
'cursor-pointer',
|
||||
isNew && 'bg-blue-500/5 dark:bg-blue-500/10',
|
||||
)}
|
||||
onClick={handleRowClick}
|
||||
>
|
||||
{row
|
||||
|
|
|
|||
Loading…
Reference in New Issue