diff --git a/src/components/DomainSearchResultsDisplay.tsx b/src/components/DomainSearchResultsDisplay.tsx
index c9b703b..9d47af9 100644
--- a/src/components/DomainSearchResultsDisplay.tsx
+++ b/src/components/DomainSearchResultsDisplay.tsx
@@ -17,6 +17,7 @@ export const DomainSearchResultsDisplay: React.FC = ({
loadMore,
cursor,
}) => {
+ const mergedRecords = mergeRecordsByValue(Array.from(records.values()));
const { ref: inViewElement, inView } = useInView();
useEffect(() => {
@@ -37,7 +38,7 @@ export const DomainSearchResultsDisplay: React.FC = ({
Search results for {domainQuery}
- {Array.from(records.values()).map((record) => (
+ {mergedRecords.map((record) => (
))}
@@ -46,3 +47,27 @@ export const DomainSearchResultsDisplay: React.FC = ({
);
};
+
+function mergeRecordsByValue(records: RecordWithSelector[]): RecordWithSelector[] {
+ const valueMap = new Map();
+
+ records.forEach((record) => {
+ if (valueMap.has(record.value)) {
+ const existing = valueMap.get(record.value)!;
+
+ existing.firstSeenAt = new Date(Math.min(existing.firstSeenAt.getTime(), record.firstSeenAt.getTime()));
+
+ if (existing.lastSeenAt && record.lastSeenAt) {
+ existing.lastSeenAt = new Date(Math.max(existing.lastSeenAt.getTime(), record.lastSeenAt.getTime()));
+ } else {
+ existing.lastSeenAt = existing.lastSeenAt || record.lastSeenAt;
+ }
+
+ valueMap.set(record.value, existing);
+ } else {
+ valueMap.set(record.value, record);
+ }
+ });
+
+ return Array.from(valueMap.values());
+}