action data refresh
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import React, { createContext, useContext, useEffect, useState } from "react";
|
||||
import { Outlet } from "react-router-dom";
|
||||
import { io } from "socket.io-client";
|
||||
import queryKeys from "../../services/queryKeys";
|
||||
import { socketEmitEvents, socketOnEvents } from "./socketEvents";
|
||||
// import io from "socket.io-client";
|
||||
|
||||
// import { tableReload } from "../../store/TableReloads";
|
||||
@@ -10,6 +13,7 @@ import { io } from "socket.io-client";
|
||||
let SocketIOContext = createContext({})
|
||||
|
||||
export default function SocketIOContextProvider({children}) {
|
||||
const queryClient = useQueryClient()
|
||||
// const {userDetails} = useSelector((state) => state?.userDetails); // CHECKS IF USER UID, to determine if user is active
|
||||
|
||||
// const dispatch = useDispatch()
|
||||
@@ -27,17 +31,22 @@ export default function SocketIOContextProvider({children}) {
|
||||
return
|
||||
};
|
||||
|
||||
const sendMessage = (message, room) => {
|
||||
const sendMessage = (eventType, message, room) => {
|
||||
if(message && room){
|
||||
socket.emit("send_message", { message, room });
|
||||
socket.emit(eventType, { message, room });
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
socket.on("receive_message", (data) => {
|
||||
socket.on(socketOnEvents.receive_message, (data) => {
|
||||
// setSocketMsgReceived(data.message);
|
||||
// dispatch(tableReload({type:'CHATMESSAGELIST'})) // dispatches to update chat message sending from owner to worker and vice versa
|
||||
console.log('DATA', data)
|
||||
queryClient.refetchQueries({
|
||||
queryKey: [...queryKeys.recentAction],
|
||||
// type: 'active',
|
||||
// exact: true,
|
||||
})
|
||||
});
|
||||
|
||||
// client-side
|
||||
|
||||
Reference in New Issue
Block a user