feature/IO-3096-GlobalNotifications - Checkpoint - Splits are now in place
This commit is contained in:
@@ -17,7 +17,17 @@ const SocketContext = createContext(null);
|
||||
|
||||
const INITIAL_NOTIFICATIONS = 10;
|
||||
|
||||
const SocketProvider = ({ children, bodyshop, navigate, currentUser }) => {
|
||||
/**
|
||||
* Socket Provider - Scenario Notifications / Web Socket related items.
|
||||
* @param children
|
||||
* @param bodyshop
|
||||
* @param navigate
|
||||
* @param currentUser
|
||||
* @param scenarioNotificationsOn
|
||||
* @returns {JSX.Element}
|
||||
* @constructor
|
||||
*/
|
||||
const SocketProvider = ({ children, bodyshop, navigate, currentUser, scenarioNotificationsOn }) => {
|
||||
const socketRef = useRef(null);
|
||||
const [clientId, setClientId] = useState(null);
|
||||
const [isConnected, setIsConnected] = useState(false);
|
||||
@@ -191,6 +201,11 @@ const SocketProvider = ({ children, bodyshop, navigate, currentUser }) => {
|
||||
};
|
||||
|
||||
const handleNotification = (data) => {
|
||||
// Scenario Notifications have been disabled, bail.
|
||||
if (!scenarioNotificationsOn) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { jobId, jobRoNumber, notificationId, associationId, notifications } = data;
|
||||
if (associationId !== userAssociationId) return;
|
||||
|
||||
@@ -295,6 +310,11 @@ const SocketProvider = ({ children, bodyshop, navigate, currentUser }) => {
|
||||
};
|
||||
|
||||
const handleSyncNotificationRead = ({ notificationId, timestamp }) => {
|
||||
// Scenario Notifications have been disabled, bail.
|
||||
if (!scenarioNotificationsOn) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const notificationRef = client.cache.identify({
|
||||
__typename: "notifications",
|
||||
@@ -336,6 +356,11 @@ const SocketProvider = ({ children, bodyshop, navigate, currentUser }) => {
|
||||
};
|
||||
|
||||
const handleSyncAllNotificationsRead = ({ timestamp }) => {
|
||||
// Scenario Notifications have been disabled, bail.
|
||||
if (!scenarioNotificationsOn) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const queryVars = {
|
||||
limit: INITIAL_NOTIFICATIONS,
|
||||
@@ -436,7 +461,8 @@ const SocketProvider = ({ children, bodyshop, navigate, currentUser }) => {
|
||||
clientId,
|
||||
isConnected,
|
||||
markNotificationRead,
|
||||
markAllNotificationsRead
|
||||
markAllNotificationsRead,
|
||||
scenarioNotificationsOn
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
|
||||
Reference in New Issue
Block a user