From 0187bc39e460dcd0ed8a76dc7f0d9f973f33ac06 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Sun, 4 Jan 2026 17:32:31 -0700 Subject: [PATCH] Fix lint --- .../views/settings/PolicyServerConfig.tsx | 69 ++++++++++++------- 1 file changed, 45 insertions(+), 24 deletions(-) diff --git a/src/components/views/settings/PolicyServerConfig.tsx b/src/components/views/settings/PolicyServerConfig.tsx index 717b8baf9f..2423c1af7e 100644 --- a/src/components/views/settings/PolicyServerConfig.tsx +++ b/src/components/views/settings/PolicyServerConfig.tsx @@ -32,18 +32,22 @@ export const PolicyServerConfig: React.FC = ({ room }) const currentPolicyServerName = policyServerEvent?.getContent()?.["via"] ?? ""; const [serverName, setServerName] = useState(currentPolicyServerName); const [error, setError] = useState(false); - const supportUrl = useAsyncMemo(async (): Promise => { - if (!currentPolicyServerName) { + const supportUrl = useAsyncMemo( + async (): Promise => { + if (!currentPolicyServerName) { + return undefined; + } + + const res = await (await fetch(`https://${currentPolicyServerName}/.well-known/matrix/support`)).json(); + if (!!res["support_page"] && typeof res["support_page"] === "string") { + return res["support_page"]; + } + return undefined; - } - - const res = await (await fetch(`https://${currentPolicyServerName}/.well-known/matrix/support`)).json(); - if (!!res["support_page"] && typeof res["support_page"] === "string") { - return res["support_page"]; - } - - return undefined; - }, [serverName, currentPolicyServerName], undefined); + }, + [serverName, currentPolicyServerName], + undefined, + ); const onSubmit = async (event: FormEvent): Promise => { event.preventDefault(); @@ -56,14 +60,21 @@ export const PolicyServerConfig: React.FC = ({ room }) try { if (serverName.trim().length > 0) { - const res = await (await fetch(`https://${serverName.trim()}/.well-known/matrix/org.matrix.msc4284.policy_server`)).json(); + const res = await ( + await fetch(`https://${serverName.trim()}/.well-known/matrix/org.matrix.msc4284.policy_server`) + ).json(); if (!!res["public_key"] && typeof res["public_key"] === "string") { - await client.sendStateEvent(room.roomId, EventType.RoomPolicy, { - via: serverName, - public_key: res["public_key"], - }, ""); + await client.sendStateEvent( + room.roomId, + EventType.RoomPolicy, + { + via: serverName, + public_key: res["public_key"], + }, + "", + ); } else { - logger.error("Policy server returned non-string public key (or returned an error)") + logger.error("Policy server returned non-string public key (or returned an error)"); setError(true); } } else { @@ -76,16 +87,24 @@ export const PolicyServerConfig: React.FC = ({ room }) } setIsLoading(false); - } + }; let supportSection: JSX.Element | undefined; if (!!currentPolicyServerName) { if (!!supportUrl) { - supportSection = { _t("room_settings|permissions|policy_server_support_page", {},{ - a: (sub) => {sub}, - }) }; + supportSection = ( + + {_t( + "room_settings|permissions|policy_server_support_page", + {}, + { + a: (sub) => {sub}, + }, + )} + + ); } else { - supportSection = { _t("room_settings|permissions|policy_server_generic_support") }; + supportSection = {_t("room_settings|permissions|policy_server_generic_support")}; } } @@ -111,8 +130,10 @@ export const PolicyServerConfig: React.FC = ({ room }) > {_t("action|apply")} - { error ? { _t("room_settings|permissions|policy_server_error") } : undefined } - { supportSection } + {error ? ( + {_t("room_settings|permissions|policy_server_error")} + ) : undefined} + {supportSection} );