Skip to content

Commit

Permalink
Fix tests and prepare for react 18.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Jul 1, 2024
1 parent 1ffa521 commit a10a0ee
Show file tree
Hide file tree
Showing 8 changed files with 266 additions and 291 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public async Task Should_send_full_message()
[Fact]
public async Task Should_fail_on_user()
{
var invalidUser = Guid.NewGuid().ToString();
// Discord only uses numbers in IDs with 18 characeters, therefore we cannot use GUID or so.
var invalidUser = "112233445566778899";

var message = new MessagingMessage
{
Expand Down
4 changes: 3 additions & 1 deletion frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ module.exports = {
"parserOptions": {
"project": "tsconfig.json"
},
"plugins": [
"plugins": [
"eslint-plugin-react-compiler",
"eslint-plugin-import",
"sort-keys-fix",
"@typescript-eslint",
Expand Down Expand Up @@ -105,6 +106,7 @@ module.exports = {
],
"operator-linebreak": "off",
"prefer-destructuring": "off",
"react-compiler/react-compiler": "error",
"sort-imports": [
"error",
{
Expand Down
520 changes: 244 additions & 276 deletions frontend/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"core-js": "3.33.2",
"date-fns": "2.30.0",
"emoji-mart": "^5.5.2",
"eslint-plugin-react-compiler": "^0.0.0-experimental-51a85ea-20240601",
"history": "^5.3.0",
"mousetrap": "1.6.5",
"oidc-client-ts": "^2.4.0",
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/app/framework/react/OverlayDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import * as ReactDOM from 'react-dom';
import { ClickOutside } from './ClickOutside';
import { useEventCallback } from './hooks';

/* eslint-disable react-hooks/exhaustive-deps */

export class OverlayController {
private static openController?: OverlayController;
private listener?: (opened: boolean) => void;
Expand Down Expand Up @@ -115,7 +113,7 @@ export const OverlayDropdown = (props: OverlayDropdownProps) => {

React.useEffect(() => {
update();
}, [show]);
}, [show, update]);

React.useEffect(() => {
return controller?.listen(value => {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/framework/react/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

/* eslint-disable no-console */
/* eslint-disable react-compiler/react-compiler */
/* eslint-disable react-hooks/exhaustive-deps */

import * as React from 'react';
Expand Down
20 changes: 13 additions & 7 deletions frontend/src/app/pages/integrations/IntegrationImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ export const IntegrationImage = (props: IntegrationImageProps) => {
};

const RenderSVG = ({ svg }: { svg: string }) => {
const [div, setDiv] = React.useState<HTMLDivElement | null>(null);

React.useEffect(() => {
if (!div || !svg) {
return;
const html = React.useMemo(() => {
if (!svg) {
return null;
}


const prefix = Numbers.guid();

const div = document.createElement('div');
div.innerHTML = svg;
div.querySelectorAll('*').forEach(element => {
const id = element.getAttribute('id');
Expand All @@ -66,9 +66,15 @@ const RenderSVG = ({ svg }: { svg: string }) => {
}
}
});
}, [div, svg]);

return { __html: div.innerHTML };
}, [svg]);

if (!html) {
return null;
}

return (
<div ref={setDiv} />
<div dangerouslySetInnerHTML={html} />
);
};
4 changes: 1 addition & 3 deletions frontend/src/app/shared/components/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { ClickOutside, Icon, OverlayDropdown, useEventCallback } from '@app/fram
import { texts } from '@app/texts';
import { MediaPicker } from './MediaPicker';

/* eslint-disable react-hooks/exhaustive-deps */

export interface PickerOptions {
// True when emojis can be added.
pickEmoji?: boolean;
Expand Down Expand Up @@ -64,7 +62,7 @@ export const Picker = (props: PickerProps) => {

React.useEffect(() => {
update();
}, [openPicker]);
}, [openPicker, update]);

const doSelectUrl = useEventCallback((url: string) => {
onPick(url);
Expand Down

0 comments on commit a10a0ee

Please sign in to comment.