Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const socketIoMiddleware = store => next => action => {
const result = next(action);
if (action.type === 'CONNECT_SOCKET') {
createSocket(store, (action.payload ?
action.payload.coreURL : store.getState().setting.coreURL
));
}
if (!socket) {
toastr.warning('websocket', "socket doesn't inital");
return result;
}
if (SendActions.indexOf(action.type) > -1) {
if (!socket.connected && action.type !== 'SETTING_CONTROLLER') {
toastr.warning('websocket', 'Not connected');
return result;
}
socket.emit(action.type, {
data: action.payload,
});
}
return result;
};
const matchResponseForNotify = (actionName, payload) => {
if (!actionName.match(notifyRule)) {
return;
}
if (payload.status !== 'OK') {
toastr.warning(actionName.toLowerCase().replace(/_/g, ' '), payload.message);
} else {
toastr.success(actionName.toLowerCase().replace(/_/g, ' '), payload.message);
}
};
handleSelect (asset) {
const { selectAsset } = this.props
if (asset.disabled) {
return toastr.warning('INVALID', `Cannot add ${asset.name}: ${asset.disabledMessage}`)
}
selectAsset(asset)
}
onCopyClick() {
const copyTextarea = this.input;
copyTextarea.select();
try {
document.execCommand('copy');
this.setState({ copied: true });
} catch (err) {
toastr.warning('Oops, unable to copy');
}
}
onCopyClick(input) {
const copyTextarea = (input === 'embed') ? this.embedInput : this.input;
copyTextarea.select();
try {
document.execCommand('copy');
this.setState({ copied: true });
} catch (err) {
toastr.warning('Oops, unable to copy');
}
if (input === 'url') {
logEvent('Share', 'Share a map from explore page', 'Copy link');
}
}