mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-22 18:22:11 +00:00
[bugfix] use match-sorter for filtering domain blocks (#1270)
This commit is contained in:
parent
1d24c1c283
commit
2b0342b231
|
@ -31,6 +31,7 @@ const adminActions = require("../redux/reducers/admin").actions;
|
||||||
const submit = require("../lib/submit");
|
const submit = require("../lib/submit");
|
||||||
const BackButton = require("../components/back-button");
|
const BackButton = require("../components/back-button");
|
||||||
const Loading = require("../components/loading");
|
const Loading = require("../components/loading");
|
||||||
|
const { matchSorter } = require("match-sorter");
|
||||||
|
|
||||||
const base = "/settings/admin/federation";
|
const base = "/settings/admin/federation";
|
||||||
|
|
||||||
|
@ -79,6 +80,10 @@ function InstanceOverview() {
|
||||||
const blockedInstances = Redux.useSelector(state => state.admin.blockedInstances);
|
const blockedInstances = Redux.useSelector(state => state.admin.blockedInstances);
|
||||||
const [_location, setLocation] = useLocation();
|
const [_location, setLocation] = useLocation();
|
||||||
|
|
||||||
|
const filteredInstances = React.useMemo(() => {
|
||||||
|
return matchSorter(Object.values(blockedInstances), filter, {keys: ["domain"]});
|
||||||
|
}, [blockedInstances, filter]);
|
||||||
|
|
||||||
function filterFormSubmit(e) {
|
function filterFormSubmit(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setLocation(`${base}/${filter}`);
|
setLocation(`${base}/${filter}`);
|
||||||
|
@ -96,7 +101,7 @@ function InstanceOverview() {
|
||||||
<Link to={`${base}/${filter}`}><a className="button">Add block</a></Link>
|
<Link to={`${base}/${filter}`}><a className="button">Add block</a></Link>
|
||||||
</form>
|
</form>
|
||||||
<div className="list">
|
<div className="list">
|
||||||
{Object.values(blockedInstances).filter((a) => a.domain.startsWith(filter)).map((entry) => {
|
{filteredInstances.map((entry) => {
|
||||||
return (
|
return (
|
||||||
<Link key={entry.domain} to={`${base}/${entry.domain}`}>
|
<Link key={entry.domain} to={`${base}/${entry.domain}`}>
|
||||||
<a className="entry nounderline">
|
<a className="entry nounderline">
|
||||||
|
|
Loading…
Reference in a new issue