Implement MSC4155: Invite filtering (#29603)
* Add settings for MSC4155 * copyright * Tweak to not use js-sdk * Update for latest MSC * Various tidyups * Move tab * i18n * update .snap * mvvm * lint * add header * Remove capability check * fix * Rewrite to use Settings * lint * lint * fix test * Tweaks * lint * revert copyright * update screenshot * cleanup
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
Copyright 2025 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import React, { type FC, useCallback, useState } from "react";
|
||||
import { Root } from "@vector-im/compound-web";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
import { _t } from "../../../../../languageHandler";
|
||||
import { useSettingValue } from "../../../../../hooks/useSettings";
|
||||
import SettingsStore from "../../../../../settings/SettingsStore";
|
||||
import { SettingLevel } from "../../../../../settings/SettingLevel";
|
||||
import LabelledToggleSwitch from "../../../elements/LabelledToggleSwitch";
|
||||
|
||||
export const InviteRulesAccountSetting: FC = () => {
|
||||
const rules = useSettingValue("inviteRules");
|
||||
const settingsDisabled = SettingsStore.disabledMessage("inviteRules");
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
const onChange = useCallback(async (checked: boolean) => {
|
||||
try {
|
||||
setBusy(true);
|
||||
await SettingsStore.setValue("inviteRules", null, SettingLevel.ACCOUNT, {
|
||||
allBlocked: !checked,
|
||||
});
|
||||
} catch (ex) {
|
||||
logger.error(`Unable to set invite rules`, ex);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}, []);
|
||||
return (
|
||||
<Root className="mx_MediaPreviewAccountSetting_Form">
|
||||
<LabelledToggleSwitch
|
||||
className="mx_MediaPreviewAccountSetting_ToggleSwitch"
|
||||
label={_t("settings|invite_controls|default_label")}
|
||||
value={!rules.allBlocked}
|
||||
onChange={onChange}
|
||||
tooltip={settingsDisabled}
|
||||
disabled={!!settingsDisabled || busy}
|
||||
/>
|
||||
</Root>
|
||||
);
|
||||
};
|
||||
@@ -33,6 +33,7 @@ import LabelledToggleSwitch from "../../../elements/LabelledToggleSwitch";
|
||||
import * as TimezoneHandler from "../../../../../TimezoneHandler";
|
||||
import { type BooleanSettingKey } from "../../../../../settings/Settings.tsx";
|
||||
import { MediaPreviewAccountSettings } from "./MediaPreviewAccountSettings.tsx";
|
||||
import { InviteRulesAccountSetting } from "./InviteRulesAccountSettings.tsx";
|
||||
|
||||
interface IProps {
|
||||
closeSettingsFn(success: boolean): void;
|
||||
@@ -339,6 +340,7 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
|
||||
|
||||
<SettingsSubsection heading={_t("common|moderation_and_safety")} legacy={false}>
|
||||
<MediaPreviewAccountSettings />
|
||||
<InviteRulesAccountSetting />
|
||||
</SettingsSubsection>
|
||||
|
||||
<SettingsSubsection heading={_t("settings|preferences|room_directory_heading")}>
|
||||
|
||||
Reference in New Issue
Block a user