Skip to content

Commit

Permalink
[bugfix] use match-sorter for filtering domain blocks (#1270)
Browse files Browse the repository at this point in the history
  • Loading branch information
f0x52 committed Dec 16, 2022
1 parent 1d24c1c commit 2b0342b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion web/source/settings/admin/federation.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const adminActions = require("../redux/reducers/admin").actions;
const submit = require("../lib/submit");
const BackButton = require("../components/back-button");
const Loading = require("../components/loading");
const { matchSorter } = require("match-sorter");

const base = "/settings/admin/federation";

Expand Down Expand Up @@ -79,6 +80,10 @@ function InstanceOverview() {
const blockedInstances = Redux.useSelector(state => state.admin.blockedInstances);
const [_location, setLocation] = useLocation();

const filteredInstances = React.useMemo(() => {
return matchSorter(Object.values(blockedInstances), filter, {keys: ["domain"]});
}, [blockedInstances, filter]);

function filterFormSubmit(e) {
e.preventDefault();
setLocation(`${base}/${filter}`);
Expand All @@ -96,7 +101,7 @@ function InstanceOverview() {
<Link to={`${base}/${filter}`}><a className="button">Add block</a></Link>
</form>
<div className="list">
{Object.values(blockedInstances).filter((a) => a.domain.startsWith(filter)).map((entry) => {
{filteredInstances.map((entry) => {
return (
<Link key={entry.domain} to={`${base}/${entry.domain}`}>
<a className="entry nounderline">
Expand Down

0 comments on commit 2b0342b

Please sign in to comment.