Skip to content

Commit

Permalink
Enable server-side search.
Browse files Browse the repository at this point in the history
  • Loading branch information
allilevine committed Jan 9, 2025
1 parent cac44f9 commit 3f16245
Showing 1 changed file with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';
import { DataViews } from '@wordpress/dataviews';
import { useTranslate } from 'i18n-calypso';
import { useMemo } from 'react';
import TimeSince from 'calypso/components/time-since';
Expand Down Expand Up @@ -36,6 +36,7 @@ const SubscriberDataViews = ( {
isOwnerSubscribed,
perPage,
setPerPage,
handleSearch,
} = useSubscribersPage();

const isSimple = useSelector( isSimpleSite );
Expand Down Expand Up @@ -114,27 +115,21 @@ const SubscriberDataViews = ( {
setPerPage( newView.perPage );
pageChangeCallback( 1 );
}

if ( typeof newView.search === 'string' && newView.search !== searchTerm ) {
handleSearch( newView.search );
}
};

const { data, paginationInfo } = useMemo( () => {
const result = filterSortAndPaginate< Subscriber >(
subscribers,
{
...currentView,
page: 1,
perPage: subscribers.length,
},
fields
);

return {
data: result.data,
data: subscribers,
paginationInfo: {
totalItems: grandTotal,
totalPages: pages ?? 0,
},
};
}, [ subscribers, currentView, fields, grandTotal, pages ] );
}, [ subscribers, grandTotal, pages ] );

return (
<section className="subscriber-data-views">
Expand Down

0 comments on commit 3f16245

Please sign in to comment.