Skip to content

Commit a10a0ee

Browse files
Fix tests and prepare for react 18.
1 parent 1ffa521 commit a10a0ee

File tree

8 files changed

+266
-291
lines changed

8 files changed

+266
-291
lines changed

backend/tests/Notifo.Domain.Tests/Integrations/Discord/DiscordTests.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ public async Task Should_send_full_message()
8080
[Fact]
8181
public async Task Should_fail_on_user()
8282
{
83-
var invalidUser = Guid.NewGuid().ToString();
83+
// Discord only uses numbers in IDs with 18 characeters, therefore we cannot use GUID or so.
84+
var invalidUser = "112233445566778899";
8485

8586
var message = new MessagingMessage
8687
{

frontend/.eslintrc.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ module.exports = {
1313
"parserOptions": {
1414
"project": "tsconfig.json"
1515
},
16-
"plugins": [
16+
"plugins": [
17+
"eslint-plugin-react-compiler",
1718
"eslint-plugin-import",
1819
"sort-keys-fix",
1920
"@typescript-eslint",
@@ -105,6 +106,7 @@ module.exports = {
105106
],
106107
"operator-linebreak": "off",
107108
"prefer-destructuring": "off",
109+
"react-compiler/react-compiler": "error",
108110
"sort-imports": [
109111
"error",
110112
{

frontend/package-lock.json

+244-276
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"core-js": "3.33.2",
2020
"date-fns": "2.30.0",
2121
"emoji-mart": "^5.5.2",
22+
"eslint-plugin-react-compiler": "^0.0.0-experimental-51a85ea-20240601",
2223
"history": "^5.3.0",
2324
"mousetrap": "1.6.5",
2425
"oidc-client-ts": "^2.4.0",

frontend/src/app/framework/react/OverlayDropdown.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import * as ReactDOM from 'react-dom';
1212
import { ClickOutside } from './ClickOutside';
1313
import { useEventCallback } from './hooks';
1414

15-
/* eslint-disable react-hooks/exhaustive-deps */
16-
1715
export class OverlayController {
1816
private static openController?: OverlayController;
1917
private listener?: (opened: boolean) => void;
@@ -115,7 +113,7 @@ export const OverlayDropdown = (props: OverlayDropdownProps) => {
115113

116114
React.useEffect(() => {
117115
update();
118-
}, [show]);
116+
}, [show, update]);
119117

120118
React.useEffect(() => {
121119
return controller?.listen(value => {

frontend/src/app/framework/react/hooks.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
/* eslint-disable no-console */
9+
/* eslint-disable react-compiler/react-compiler */
910
/* eslint-disable react-hooks/exhaustive-deps */
1011

1112
import * as React from 'react';

frontend/src/app/pages/integrations/IntegrationImage.tsx

+13-7
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ export const IntegrationImage = (props: IntegrationImageProps) => {
3232
};
3333

3434
const RenderSVG = ({ svg }: { svg: string }) => {
35-
const [div, setDiv] = React.useState<HTMLDivElement | null>(null);
36-
37-
React.useEffect(() => {
38-
if (!div || !svg) {
39-
return;
35+
const html = React.useMemo(() => {
36+
if (!svg) {
37+
return null;
4038
}
39+
4140

4241
const prefix = Numbers.guid();
4342

43+
const div = document.createElement('div');
4444
div.innerHTML = svg;
4545
div.querySelectorAll('*').forEach(element => {
4646
const id = element.getAttribute('id');
@@ -66,9 +66,15 @@ const RenderSVG = ({ svg }: { svg: string }) => {
6666
}
6767
}
6868
});
69-
}, [div, svg]);
69+
70+
return { __html: div.innerHTML };
71+
}, [svg]);
72+
73+
if (!html) {
74+
return null;
75+
}
7076

7177
return (
72-
<div ref={setDiv} />
78+
<div dangerouslySetInnerHTML={html} />
7379
);
7480
};

frontend/src/app/shared/components/Picker.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import { ClickOutside, Icon, OverlayDropdown, useEventCallback } from '@app/fram
88
import { texts } from '@app/texts';
99
import { MediaPicker } from './MediaPicker';
1010

11-
/* eslint-disable react-hooks/exhaustive-deps */
12-
1311
export interface PickerOptions {
1412
// True when emojis can be added.
1513
pickEmoji?: boolean;
@@ -64,7 +62,7 @@ export const Picker = (props: PickerProps) => {
6462

6563
React.useEffect(() => {
6664
update();
67-
}, [openPicker]);
65+
}, [openPicker, update]);
6866

6967
const doSelectUrl = useEventCallback((url: string) => {
7068
onPick(url);

0 commit comments

Comments
 (0)