Fixing instance blocking. Fixes #2245 (#2246)

This commit is contained in:
Dessalines 2023-11-28 21:12:23 -05:00 committed by GitHub
parent 69a3a63dfd
commit 48ed65639a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -35,7 +35,7 @@ import {
SuccessResponse, SuccessResponse,
UpdateTotpResponse, UpdateTotpResponse,
} from "lemmy-js-client"; } from "lemmy-js-client";
import { elementUrl, emDash, relTags } from "../../config"; import { elementUrl, emDash, fetchLimit, relTags } from "../../config";
import { FirstLoadService, UserService } from "../../services"; import { FirstLoadService, UserService } from "../../services";
import { import {
EMPTY_REQUEST, EMPTY_REQUEST,
@ -276,6 +276,7 @@ export class Settings extends Component<any, SettingsState> {
...this.state, ...this.state,
personBlocks: mui.person_blocks, personBlocks: mui.person_blocks,
communityBlocks: mui.community_blocks, communityBlocks: mui.community_blocks,
instanceBlocks: mui.instance_blocks,
saveUserSettingsForm: { saveUserSettingsForm: {
...this.state.saveUserSettingsForm, ...this.state.saveUserSettingsForm,
show_nsfw, show_nsfw,
@ -1240,16 +1241,16 @@ export class Settings extends Component<any, SettingsState> {
searchInstanceOptions = searchInstanceOptions =
this.state.instancesRes.data.federated_instances?.linked.filter( this.state.instancesRes.data.federated_instances?.linked.filter(
instance => instance =>
instance.domain.toLowerCase().includes(text.toLowerCase()) || instance.domain.toLowerCase().includes(text.toLowerCase()) &&
!this.state.instanceBlocks.some( !this.state.instanceBlocks.some(
blockedIntance => blockedIntance.instance.id === instance.id, blockedInstance => blockedInstance.instance.id === instance.id,
), ),
) ?? []; ) ?? [];
} }
this.setState({ this.setState({
searchInstanceOptions: searchInstanceOptions searchInstanceOptions: searchInstanceOptions
.slice(0, 30) .slice(0, fetchLimit)
.map(instanceToChoice), .map(instanceToChoice),
}); });
}); });
@ -1552,7 +1553,7 @@ export class Settings extends Component<any, SettingsState> {
} }
} }
handleImportFileChange(i: Settings, event) { handleImportFileChange(i: Settings, event: any) {
i.setState({ settingsFile: event.target.files?.item(0) }); i.setState({ settingsFile: event.target.files?.item(0) });
} }