rasa-webchat
rasa-webchat copied to clipboard
Not sure about what is the purpose of dispatch evalUrl function
trafficstars
hi I have two questions below
- May I know what is the purpose of this function ?
- why we need to dispatch evalUrl method every 500 milliseconds ?
Below is source code
Path: packages\chatbot-rasa-webchat\src\components\Widget\index.js
this.intervalId = setInterval(() => dispatch(evalUrl(window.location.href)), 500);
Path: packages\chatbot-rasa-webchat\src\store\store.js
case actionTypes.EVAL_URL: {
const pageCallbacks = store.getState().behavior.get('pageChangeCallbacks');
const pageCallbacksJs = pageCallbacks ? pageCallbacks.toJS() : {};
const newUrl = action.url;
if (!pageCallbacksJs.pageChanges) break;
if (store.getState().behavior.get('oldUrl') !== newUrl) {
const { pageChanges, errorIntent } = pageCallbacksJs;
const matched = pageChanges.some((callback) => {
if (callback.regex) {
if (newUrl.match(callback.url)) {
emitMessage(callback.callbackIntent);
return true;
}
} else {
let cleanCurrentUrl = cleanURL(newUrl);
let cleanCallBackUrl = cleanURL(callback.url);
if (!cleanCallBackUrl.match(/\?.+$/)) {
// the callback does not have a querystring
cleanCurrentUrl = trimQueryString(cleanCurrentUrl);
cleanCallBackUrl = trimQueryString(cleanCallBackUrl);
}
if (cleanCurrentUrl === cleanCallBackUrl) {
emitMessage(callback.callbackIntent);
return true;
}
return false;
}
});
if (!matched) emitMessage(errorIntent);
}
break;
}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.