Skip to content

Commit

Permalink
update the onmessage on phase planner
Browse files Browse the repository at this point in the history
  • Loading branch information
MahtabBukhari committed Dec 5, 2024
1 parent 429341a commit 5f24faa
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions src/people/widgetViews/PhasePlannerView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -94,7 +111,7 @@ const PhasePlannerView: React.FC = () => {
socket.close();
}
};
}, []);
}, [main]);

const getFeatureData = useCallback(async () => {
if (!feature_uuid) return;
Expand Down

0 comments on commit 5f24faa

Please sign in to comment.