Skip to content

Commit 12f6e33

Browse files
authored
MR - Subtitles rework + add broadcast (#38)
* fix(broadcast): change check success statusCode * pending(broadcast): add .on & emitters fix statusCode 201 to 200 * pending(broadcast): add areas update broadcast + prepare subtitles broadcast * fix(broadcast socket): add boolean to make sure that the listenning is not multiplied * feat(socket): add getSubtitlesSettings & getAllTextFields * fix(): listener is destroyed after closing component * fix(compressor): align center * rework(subtitles): list subtitles text fields * add subtitles text field * remove subtitles text field * broadcast * ui/ux * fix merge conflict stah mescouilles * fix(): merge error + change display text + avoid conflict variable name * fix(): empty subtitles handling * fix(): remove success notif + remove debug * fix(): text change -> easier to understand
1 parent 2fa0490 commit 12f6e33

File tree

12 files changed

+585
-105
lines changed

12 files changed

+585
-105
lines changed

public/electron.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,71 @@ ipcMain.on("getActReactCouples", (event, arg) => {
182182
}
183183
});
184184

185+
ipcMain.on("getSubtitlesSettings", (event, arg) => {
186+
if (isDev) {
187+
let res = {
188+
statusCode: 200,
189+
message: "OK",
190+
data: {
191+
length: 2,
192+
text_fields: [
193+
{
194+
"uuid": "27705058-7a54-4057-ad17-a810c08e8db9",
195+
"name": "Text lambda 1",
196+
},
197+
{
198+
"uuid": "4f712d61-094a-4b7b-9905-4fa928329de4",
199+
"name": "Text EN",
200+
}
201+
],
202+
}
203+
};
204+
event.returnValue = res;
205+
return res;
206+
} else {
207+
return tcpConn.getSubtitlesSettings().then((res) => {
208+
console.log("getSubtitlesSettings : " + res);
209+
event.returnValue = res;
210+
});
211+
}
212+
});
213+
214+
ipcMain.on("getAllTextFields", (event, arg) => {
215+
if (isDev) {
216+
let res = {
217+
statusCode: 200,
218+
message: "OK",
219+
data: {
220+
length: 3,
221+
text_fields: [
222+
{
223+
"name": "Text lambda 1",
224+
"parent_scene": "Scene 1",
225+
"uuid": "27705058-7a54-4057-ad17-a810c08e8db9",
226+
},
227+
{
228+
"name": "Text EN",
229+
"parent_scene": "Scene 1",
230+
"uuid": "4f712d61-094a-4b7b-9905-4fa928329de4",
231+
},
232+
{
233+
"name": "Blop 3",
234+
"parent_scene": "Scene 2",
235+
"uuid": "4fa92094a-832-94fde4-712d61-4b7b-9905",
236+
}
237+
],
238+
}
239+
};
240+
event.returnValue = res;
241+
return res;
242+
} else {
243+
return tcpConn.getAllTextFields().then((res) => {
244+
console.log("getAllTextFields : " + res);
245+
event.returnValue = res;
246+
});
247+
}
248+
});
249+
185250
ipcMain.on("setCompressorLevel", (event, arg) => {
186251
if (isDev) {
187252
let res = {
@@ -263,6 +328,14 @@ ipcMain.on("scenes-updated", (evt, arg) => { // Get from socket broadcast
263328
mainWindow.webContents.send('scenes-updated'); // To renderer
264329
});
265330

331+
ipcMain.on("actions-reactions-updated", (evt, arg) => { // Get from socket broadcast
332+
mainWindow.webContents.send('actions-reactions-updated'); // To renderer
333+
});
334+
335+
ipcMain.on("subtitles-updated", (evt, arg) => { // Get from socket broadcast
336+
mainWindow.webContents.send('subtitles-updated'); // To renderer
337+
});
338+
266339
ipcMain.on("connection-server-lost", (evt, arg) => {
267340
// Quit main app
268341
if (mainWindow)

src/Components/ActionsReactions/ActionsReactions.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Component, useEffect, useState } from "react";
1+
import React, { useEffect } from "react";
22
import "./ActionsReactions.css";
33

44
import Card from "@mui/material/Card";
@@ -133,7 +133,18 @@ export const ActionsReactions = () => {
133133

134134
// Hook to load actions and reactions on component mount
135135
useEffect(() => {
136-
ipcRenderer.on('scenes-updated', (evt: any, message: any) => {
136+
const handleActionReactionUpdated = (evt: any, message: any) => {
137+
getActionReactionFromServer().then((res) => {
138+
if (res.statusCode === 200) {
139+
toast("Actions/Reactions have been updated !", {
140+
type: "info",
141+
});
142+
console.log("New Array", res);
143+
setActionsReactionsList(res.data.actReacts);
144+
}
145+
});
146+
};
147+
const handleScenesUpdated = (evt: any, message: any) => {
137148
getAllScenes().then((res) => {
138149
if (res.statusCode === 200) {
139150
toast("Scenes have been updated.", {
@@ -142,7 +153,11 @@ export const ActionsReactions = () => {
142153
setAvailableScenes(res.data.scenes);
143154
}
144155
});
145-
});
156+
};
157+
158+
ipcRenderer.on('actions-reactions-updated', handleActionReactionUpdated);
159+
ipcRenderer.on('scenes-updated', handleScenesUpdated);
160+
146161
async function sleep(): Promise<boolean> {
147162
return new Promise((resolve) => {
148163
getActionReactionFromServer().then((res) => {
@@ -174,6 +189,11 @@ export const ActionsReactions = () => {
174189
}
175190

176191
sleep().then((res) => setload(!res));
192+
193+
return () => {
194+
ipcRenderer.removeListener('actions-reactions-updated', handleActionReactionUpdated);
195+
ipcRenderer.removeListener('scenes-updated', handleScenesUpdated);
196+
};
177197
}, []);
178198

179199
/**

src/Components/ActionsReactions/AddAppLaunch/AppLaunchModal/AppLaunchModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export const AppLaunchModal = (props: any) => {
172172
<InputLabel
173173
id="demo-simple-select-label"
174174
className={classes.selectLabel}>
175-
sources
175+
reactions
176176
</InputLabel>
177177
<Select
178178
labelId="demo-simple-select-label"

src/Components/ActionsReactions/AddNewKeyPressed/KeyPressedModal/KeyPressedModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export const KeyPressedModal = (props: any) => {
187187
<InputLabel
188188
id="demo-simple-select-label"
189189
className={classes.selectLabel}>
190-
sources
190+
reactions
191191
</InputLabel>
192192
<Select
193193
labelId="demo-simple-select-label"

src/Components/ActionsReactions/AddNewWord/WordDetectionModal/WordDetectionModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export const WordDetectionModal = (props: any) => {
190190
<InputLabel
191191
id="demo-simple-select-label"
192192
className={classes.selectLabel}>
193-
sources
193+
reactions
194194
</InputLabel>
195195
<Select
196196
labelId="demo-simple-select-label"

src/Components/ActionsReactions/CreateReactions/CreateReactions.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const CreateReactions = () => {
6666
);
6767
const [availableScenes, setAvailableScenes] = React.useState<Scene[]>([]);
6868

69-
69+
7070
/**
7171
* Define styles for the component
7272
*/
@@ -266,7 +266,7 @@ export const CreateReactions = () => {
266266
}
267267

268268
useEffect(() => {
269-
ipcRenderer.on('scenes-updated', (evt: any, message: any) => {
269+
const handleScenesUpdated = (evt: any, message: any) => {
270270
getAllScenes().then((res) => {
271271
if (res.statusCode === 200) {
272272
toast("Scenes have been updated.", {
@@ -275,7 +275,10 @@ export const CreateReactions = () => {
275275
setAvailableScenes(res.data.scenes);
276276
}
277277
});
278-
});
278+
};
279+
280+
ipcRenderer.on('scenes-updated', handleScenesUpdated);
281+
279282
getAllScenes().then((res) => {
280283
if (res.statusCode === 200) {
281284
setAvailableScenes(res.data.scenes);
@@ -287,6 +290,9 @@ export const CreateReactions = () => {
287290
}
288291
});
289292

293+
return () => {
294+
ipcRenderer.removeListener('scenes-updated', handleScenesUpdated);
295+
};
290296
}, []);
291297

292298
return (
@@ -372,7 +378,7 @@ export const CreateReactions = () => {
372378
<TextField
373379
autoFocus
374380
id="name"
375-
label="Name of the action"
381+
label="Name of the reaction"
376382
type="text"
377383
value={newActionName}
378384
variant="standard"
@@ -404,7 +410,7 @@ export const CreateReactions = () => {
404410
{
405411
newActionSelected === "SCENE_SWITCH" ? (
406412
<>
407-
<InputLabel id="select-event-label">Parameter action</InputLabel>
413+
<InputLabel id="select-event-label">Parameter reaction</InputLabel>
408414
<Select
409415
labelId="select-event-label"
410416
id="select-event"

src/Components/CompressorLevel/CompressorLevel.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Component, useEffect, useState } from "react";
1+
import React, { useEffect } from "react";
22
import CustomizedSlider from "../Slider/Slider";
33
import { AllMics, Mic } from "../../Socket/interfaces";
44
import { resultFormat } from "../../Socket/interfaces";
@@ -17,6 +17,7 @@ export const CompressorLevel = () => {
1717
>([]);
1818
const [load, setload] = React.useState(true);
1919
const [point, setpoint] = React.useState(".");
20+
2021
const axiosPrivate = useAxiosPrivate();
2122

2223
const style = {
@@ -31,8 +32,6 @@ export const CompressorLevel = () => {
3132
},
3233
};
3334

34-
let timeoutCommit: NodeJS.Timeout | undefined = undefined;
35-
3635
const getAllCompressors = (): Promise<AllMics> => {
3736
return new Promise(async (resolve, reject) => {
3837
const result: AllMics = await ipcRenderer.sendSync("getAllMics", "ping");
@@ -69,13 +68,16 @@ export const CompressorLevel = () => {
6968
};
7069

7170
useEffect(() => {
72-
ipcRenderer.on('compressor-level-updated', (evt: any, message: any) => {
71+
const handleCompressorLevelUpdated = (evt: any, message: any) => {
7372
getAllCompressors().then((res) => {
7473
if (res.statusCode === 200) {
7574
setExampleCompressorArray(res.data.mics);
7675
}
7776
});
78-
})
77+
};
78+
79+
ipcRenderer.on('compressor-level-updated', handleCompressorLevelUpdated);
80+
7981
async function sleep(): Promise<boolean> {
8082
return new Promise((resolve) => {
8183
getAllCompressors().then((res) => {
@@ -88,6 +90,10 @@ export const CompressorLevel = () => {
8890
}
8991

9092
sleep().then((res) => setload(res));
93+
94+
return () => {
95+
ipcRenderer.removeListener('compressor-level-updated', handleCompressorLevelUpdated);
96+
};
9197
}, []);
9298

9399
function addpoint() {

src/Components/Slider/Slider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ const CustomizedSlider = (props: any) => {
105105
sx={{
106106
display: "flex",
107107
alignItems: "center",
108+
justifyContent: "space-evenly",
108109
p: 1,
109110
m: 1,
110111
}}
@@ -120,7 +121,7 @@ const CustomizedSlider = (props: any) => {
120121
/>
121122
</Box>
122123
<Box
123-
sx={{ marginTop: "-22px", paddingLeft: "5vw" }}
124+
sx={{ marginTop: "-20px"}}
124125
onClick={handleMicToggle}
125126
style={{ color: props.isActive ? "green" : "red" }}
126127
>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.subtitlesSettingsBox {
2+
border: 3px solid orange;
3+
background-color: #565d68;
4+
/* rounded */
5+
border-radius: 10px;
6+
7+
overflow:scroll;
8+
overflow-y:scroll;
9+
overflow-x:hidden;
10+
11+
max-height: 65vh;
12+
}
13+
14+
.subtitlesSettingsItem:hover {
15+
box-shadow: 20px;
16+
transform: scale(1.02);
17+
}
18+
19+
.MuiListItemText-secondary {
20+
color: orange !important;
21+
}

0 commit comments

Comments
 (0)