From ff196dc51750d7d29dd6e6e9f89229f11989aa60 Mon Sep 17 00:00:00 2001 From: MahtabBukhari Date: Thu, 5 Dec 2024 12:52:19 +0500 Subject: [PATCH 1/2] update the onmessage on phase planner --- src/people/widgetViews/PhasePlannerView.tsx | 35 +++++++++++++++------ 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/people/widgetViews/PhasePlannerView.tsx b/src/people/widgetViews/PhasePlannerView.tsx index 41aa9da5..f82c188c 100644 --- a/src/people/widgetViews/PhasePlannerView.tsx +++ b/src/people/widgetViews/PhasePlannerView.tsx @@ -59,6 +59,16 @@ const PhasePlannerView: React.FC = () => { console.log('Socket connected in Phase Planner'); }; + const refreshSingleTicket = async (ticketUuid: string) => { + try { + const ticket = await main.getTicketDetails(ticketUuid); + + phaseTicketStore.updateTicket(ticket.uuid, ticket); + } catch (error) { + console.error('Error refreshing ticket:', error); + } + }; + socket.onmessage = (event: MessageEvent) => { try { const data = JSON.parse(event.data); @@ -71,14 +81,21 @@ const PhasePlannerView: React.FC = () => { } const ticketMessage = data as TicketMessage; - if (ticketMessage.action === 'message') { - console.log('Received ticket message:', ticketMessage.message); - console.log('Ticket details:', { - broadcastType: ticketMessage.broadcastType, - sourceSessionID: ticketMessage.sourceSessionID, - action: ticketMessage.action, - ticketDetails: ticketMessage.ticketDetails - }); + switch (ticketMessage.action) { + case 'message': + console.log('Received ticket message:', ticketMessage.message); + console.log('Ticket details:', { + broadcastType: ticketMessage.broadcastType, + sourceSessionID: ticketMessage.sourceSessionID, + action: ticketMessage.action, + ticketDetails: ticketMessage.ticketDetails + }); + break; + + case 'process': + console.log('Processing ticket update:', ticketMessage.ticketDetails.uuid); + refreshSingleTicket(ticketMessage.ticketDetails.uuid); + break; } } catch (error) { console.error('Error processing websocket message:', error); @@ -94,7 +111,7 @@ const PhasePlannerView: React.FC = () => { socket.close(); } }; - }, []); + }, [main]); const getFeatureData = useCallback(async () => { if (!feature_uuid) return; From a5aed924bba4b20a22afb72834eed18fd93cf0a8 Mon Sep 17 00:00:00 2001 From: MahtabBukhari Date: Thu, 5 Dec 2024 14:20:31 +0500 Subject: [PATCH 2/2] console ticket message --- src/people/widgetViews/PhasePlannerView.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/people/widgetViews/PhasePlannerView.tsx b/src/people/widgetViews/PhasePlannerView.tsx index 3ee0a185..919865b2 100644 --- a/src/people/widgetViews/PhasePlannerView.tsx +++ b/src/people/widgetViews/PhasePlannerView.tsx @@ -81,6 +81,9 @@ const PhasePlannerView: React.FC = () => { } const ticketMessage = data as TicketMessage; + + console.log('Ticket Message', ticketMessage); + switch (ticketMessage.action) { case 'message': console.log('Received ticket message:', ticketMessage.message);