Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(props) {
super(props);
this.state = {
webChatStore: createStore(
{},
({ dispatch }) => next => action => {
// console.log(action);
try {
const { payload, type } = action;
if (type === 'DIRECT_LINE/INCOMING_ACTIVITY') {
const { activity } = payload;
if (
activity.type === 'event'
&& activity.name === 'ActiveRoute.Directions'
) {
console.log(activity);
let store;
window.addEventListener('keydown', event => {
const { ctrlKey, keyCode } = event;
if (ctrlKey && keyCode === 82) {
// CTRL-R
sessionStorage.removeItem(REDUX_STORE_KEY);
} else if (ctrlKey && keyCode === 83) {
// CTRL-S
event.preventDefault();
store && console.log(store.getState());
}
});
store = createStore(
onErrorResumeNext(() => JSON.parse(window.sessionStorage.getItem(REDUX_STORE_KEY))),
({ dispatch }) => next => action => {
if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
dispatch({
type: 'WEB_CHAT/SEND_EVENT',
payload: { name: 'webchat/join', value: { language: window.navigator.language } }
});
}
return next(action);
}
);
store.subscribe(() => {
sessionStorage.setItem(REDUX_STORE_KEY, JSON.stringify(store.getState()));
});
window.hideWebchat = () => {
this.handleMinimizeButtonClick();
};
window.insertStepAt =
window.insertStepAt ||
(() => {
console.log('Cannot find API insertStepAt');
});
window.insertTypeAt =
window.insertTypeAt ||
(() => {
console.log('Cannot find API insertStepAt');
});
const store = createStore({}, ({ dispatch }) => next => action => {
if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
setTimeout(() => {
dispatch({
type: 'WEB_CHAT/SEND_EVENT',
payload: {
name: 'webchat/join',
value: {
language: window.navigator.language,
},
},
});
}, 1000);
} else if (action.type === 'DIRECT_LINE/INCOMING_ACTIVITY') {
if (action.payload.activity.from.role === 'bot') {
this.setState(() => ({ newMessage: true }));
}
constructor(props) {
super(props);
this.store = createStore({}, dispatchIncomingActivityMiddleware(props.appDispatch));
this.state = {};
}
constructor(props) {
super(props);
this.handleFetchToken = this.handleFetchToken.bind(this);
this.handleMaximizeButtonClick = this.handleMaximizeButtonClick.bind(this);
this.handleMinimizeButtonClick = this.handleMinimizeButtonClick.bind(this);
this.handleSwitchButtonClick = this.handleSwitchButtonClick.bind(this);
const store = createStore({}, ({ dispatch }) => next => action => {
if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
setTimeout(() => {
dispatch({
type: 'WEB_CHAT/SEND_EVENT',
payload: {
name: 'webchat/join',
value: {
language: window.navigator.language
}
}
});
}, 1000);
} else if (action.type === 'DIRECT_LINE/INCOMING_ACTIVITY') {
if (action.payload.activity.from.role === 'bot') {
this.setState(() => ({ newMessage: true }));
}