Skip to content

Commit f4dd405

Browse files
authored
Merge pull request #51 from WildCodeSchool/US05-fix-bug-group
fix bug des group qui ne ce sélectrionne pas
2 parents 50b9c27 + 1f39db6 commit f4dd405

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

frontend/src/pages/Conversations.tsx

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -119,37 +119,37 @@ export default function Conversations() {
119119
chat.connectToRoom(groupData?.getAllMyGroups.groupToken);
120120
}, [groupData, chat]);
121121

122-
useEffect(() => {
123-
if (!groupData?.getAllMyGroups) return;
124-
125-
if (groupData?.getAllMyGroups.groups.length === 0) {
126-
setIndexGroup(-1);
127-
setSelectedGroupId(null);
128-
return;
129-
}
130-
131-
const newGroups = groupData?.getAllMyGroups.groups || [];
132-
setGroups(newGroups);
133-
134-
// Initialize messages map with empty arrays for all groups
135-
setMessages((prev) => {
136-
const updated = { ...prev };
137-
newGroups.forEach((group) => {
138-
const groupId = Number(group.id);
139-
if (!updated[groupId]) {
140-
updated[groupId] = [];
141-
}
142-
});
143-
return updated;
144-
});
145-
146-
const existing =
147-
indexGroups !== -1
148-
? groupData?.getAllMyGroups.groups.find((group) => Number(group.id) === Number(indexGroups))
149-
: null;
150-
151-
setIndexGroup(existing ? indexGroups : 0);
152-
}, [groupData, indexGroups]);
122+
// useEffect(() => {
123+
// if (!groupData?.getAllMyGroups) return;
124+
125+
// if (groupData?.getAllMyGroups.groups.length === 0) {
126+
// setIndexGroup(-1);
127+
// setSelectedGroupId(null);
128+
// return;
129+
// }
130+
131+
// const newGroups = groupData?.getAllMyGroups.groups || [];
132+
// setGroups(newGroups);
133+
134+
// // Initialize messages map with empty arrays for all groups
135+
// setMessages((prev) => {
136+
// const updated = { ...prev };
137+
// newGroups.forEach((group) => {
138+
// const groupId = Number(group.id);
139+
// if (!updated[groupId]) {
140+
// updated[groupId] = [];
141+
// }
142+
// });
143+
// return updated;
144+
// });
145+
146+
// const existing =
147+
// indexGroups !== -1
148+
// ? groupData?.getAllMyGroups.groups.find((group) => Number(group.id) === Number(indexGroups))
149+
// : null;
150+
151+
// setIndexGroup(existing ? indexGroups : 0);
152+
// }, [groupData, indexGroups]);
153153

154154
// pour set les messages initiaux
155155
useEffect(() => {

0 commit comments

Comments
 (0)