Skip to content
Extraits de code Groupes Projets
Valider 910a259d rédigé par chaimaa hassoune's avatar chaimaa hassoune
Parcourir les fichiers

Merge branch 'develop' of http://mc-git.com/mydressin/mydressin-front into develop

parents 104f935b 1caf3d0b
Branches
1 requête de fusion!503MS-123 /Implement export of users and products
Pipeline #17797 réussi avec l'étape
in 4 minutes et 55 secondes
......@@ -100,7 +100,17 @@ export const LiveCommentsProvider = ({ children, liveId }: Props) => {
// WebSocket management
const connect = useCallback(() => {
if (!mountedRef.current || clientRef.current?.connected) return;
// Always disconnect any existing client and unsubscribe before connecting
if (clientRef.current) {
try {
subscriptionRef.current?.unsubscribe();
clientRef.current.disconnect(() => {
console.log("Cleaned up previous WebSocket connection");
});
} catch (e) { /* ignore */ }
clientRef.current = null;
}
if (!mountedRef.current) return;
const socket = new SockJS(WEB_SOCKET_URL || "http://localhost:8082/ws");
const client = Stomp.over(socket);
......@@ -110,7 +120,6 @@ export const LiveCommentsProvider = ({ children, liveId }: Props) => {
if (!mountedRef.current) return;
reconnectAttempts.current = 0;
reconnectDelay.current = INITIAL_RECONNECT_DELAY;
subscriptionRef.current = client.subscribe(
`/topic/messages/${liveId}`,
handleMessage
......
......@@ -367,8 +367,8 @@ export async function unpinCommentLive(commentId: string, liveId: string) {
}
export async function blockUserLive(userId: string, liveId: string) {
await axiosInstance.post(endpoints.comments.blockUser(userId, liveId));
export async function blockUserLive(sender: string, liveId: string) {
await axiosInstance.post(endpoints.comments.blockUser(sender, liveId));
}
......
......@@ -62,8 +62,8 @@ export const endpoints = {
`/api/stream/chat/live/pin?streamId=${liveId}&messageId=${commentId}`,
unpin: (commentId: string, liveId: string) =>
`/api/stream/chat/live/unpin?streamId=${liveId}&messageId=${commentId}`,
blockUser: (senderName: string, liveId: string) =>
`/api/stream/chat/block-user?streamId=${liveId}&senderName=${senderName}`,
blockUser: (sender: string, liveId: string) =>
`/api/stream/chat/block-user?streamId=${liveId}&sender=${sender}`,
export: (liveId: string) => `/api/stream/chat/live/export?streamId=${liveId}`,
},
notification: {
......
......@@ -36,7 +36,7 @@ export default function LiveCommentItem({ comment, changeParentComment }: Props)
const handleBlockUser = async () => {
try {
await blockUserLive(comment.senderName as string, comment.liveStream);
await blockUserLive(comment.sender as string, comment.liveStream);
enqueueSnackbar('utilisateur bloqué', { variant: 'success' });
} catch (error) {
enqueueSnackbar('Erreur lors du blocage de l\'utilisateur', { variant: 'error' });
......
......@@ -65,6 +65,7 @@ export type ILiveComment = {
type?: string;
pinned?: boolean;
admin?: boolean;
sender?: string;
senderName: string;
liveStream: string;
}
......
0% ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter