👀 Auto-adder WIP

This commit is contained in:
2021-10-11 14:53:49 -07:00
parent 53b7e94135
commit 9ff79320da
5 changed files with 20 additions and 6 deletions

View File

@@ -3,6 +3,7 @@ import io, { Socket } from "socket.io-client";
import { SOCKET_BASE_URI } from "../../constants/endpoints";
import { useDispatch } from "react-redux";
import { RMQ_SOCKET_CONNECTED } from "../../constants/action-types";
import { success } from "react-notification-system-redux";
const WebSocketContext = createContext(null);
export const WebSocketProvider = ({ children }): ReactElement => {
@@ -16,6 +17,20 @@ export const WebSocketProvider = ({ children }): ReactElement => {
socketId: socket.id,
});
});
// on cover extraction
socket.on("coverExtracted", (data) => {
console.log("shaket", data);
dispatch(
success({
// uid: 'once-please', // you can specify your own uid if required
title: "Cover Extracted",
message: `<span class="icon-text has-text-success"><i class="fas fa-plug"></i></span> Socket <span class="has-text-info">${socket.id}</span> connected. <strong>${data}</strong>`,
dismissible: "click",
position: "tr",
autoDismiss: 0,
}),
);
})
socket.on("disconnect", () => {
console.log(`disconnect`);
});