Improve webhook code editor performance (#601)

* Improve webhook code editor performance

* Add newsfile
This commit is contained in:
Christian Paul 2023-01-06 13:02:13 +01:00 committed by GitHub
parent 8e8a1a6958
commit 8eab1ff750
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

1
changelog.d/601.bugfix Normal file
View File

@ -0,0 +1 @@
Improve webhook code editor performance.

View File

@ -26,7 +26,7 @@ const EXAMPLE_SCRIPT = `if (data.counter === undefined) {
}`;
const DOCUMENTATION_LINK = "https://matrix-org.github.io/matrix-hookshot/latest/setup/webhooks.html#script-api";
const CODE_MIRROR_EXTENSIONS = [javascript({})];
const ConnectionConfiguration: FunctionComponent<ConnectionConfigurationProps<ServiceConfig, GenericHookResponseItem, GenericHookConnectionState>> = ({serviceConfig, existingConnection, onSave, onRemove}) => {
const [transFn, setTransFn] = useState<string>(existingConnection?.config.transformationFunction as string || EXAMPLE_SCRIPT);
@ -61,10 +61,8 @@ const ConnectionConfiguration: FunctionComponent<ConnectionConfigurationProps<Se
<InputField visible={transFnEnabled} noPadding={true}>
<CodeMirror
value={transFn}
extensions={[javascript({ })]}
onChange={(value) => {
setTransFn(value)
}}
extensions={CODE_MIRROR_EXTENSIONS}
onChange={setTransFn}
/>
<p> See the <a target="_blank" rel="noopener noreferrer" href={DOCUMENTATION_LINK}>documentation</a> for help writing transformation functions </p>
</InputField>