Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const makeSocket = jwt => {
if (socket || !jwt) return;
const qs = createQueryString({ jwt });
socket = new WebSocketClient(`${config.wsServerUrl}/${qs}`);
socket.onmessage = event => {
const { type, payload, meta: socketMeta } = JSON.parse(event.data);
const meta = {
...socketMeta,
currentUser: selectCurrentUser(store.getState())
};
if (
type === Event.SOCKET_REGISTRATION.SUCCESS &&
payload.user.id === meta.currentUser.id
) {
store.dispatch(isUserFollowing(meta.eventId));
}
const makeSocket = jwt => {
if (socket || !jwt) return;
const qs = createQueryString({ jwt });
socket = new WebSocketClient(`${config.wsServerUrl}/${qs}`);
socket.onmessage = event => {
const { type, payload, meta: socketMeta } = JSON.parse(event.data);
const meta = {
...socketMeta,
currentUser: selectCurrentUser(store.getState())
};
store.dispatch({ type, payload, meta });
const message = meta.successMessage || meta.errorMessage;
if (message) {
store.dispatch(addToast({ message }));
}
};