mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-02-15 07:28:59 +00:00
Fix donation receipt sorting to show most recent year first
Co-authored-by: yash-signal <yash@signal.org>
This commit is contained in:
@@ -364,14 +364,18 @@ function PreferencesReceiptList({
|
||||
[donationReceipts]
|
||||
);
|
||||
|
||||
const receiptsByYear = useMemo(() => {
|
||||
const receiptsByYearEntries = useMemo(() => {
|
||||
const sortedReceipts = sortBy(
|
||||
donationReceipts,
|
||||
receipt => -receipt.timestamp
|
||||
);
|
||||
return groupBy(sortedReceipts, receipt =>
|
||||
const yearToReceipts = groupBy(sortedReceipts, receipt =>
|
||||
new Date(receipt.timestamp).getFullYear()
|
||||
);
|
||||
|
||||
return Object.entries(yearToReceipts).sort(
|
||||
([yearA], [yearB]) => parseInt(yearB, 10) - parseInt(yearA, 10)
|
||||
);
|
||||
}, [donationReceipts]);
|
||||
|
||||
const handleDownloadReceipt = useCallback(async () => {
|
||||
@@ -428,7 +432,7 @@ function PreferencesReceiptList({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{Object.entries(receiptsByYear).map(([year, receipts]) => (
|
||||
{receiptsByYearEntries.map(([year, receipts]) => (
|
||||
<div
|
||||
key={year}
|
||||
className="PreferencesDonations--receiptList-yearContainer"
|
||||
|
||||
Reference in New Issue
Block a user