Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim committed Dec 4, 2019
1 parent 11b3c85 commit 50336ad
Showing 1 changed file with 23 additions and 18 deletions.
Expand Up @@ -10,27 +10,32 @@ import stopDictate from '../actions/stopDictate';
import whileConnected from './effects/whileConnected';

function* speakActivityAndStartDictateOnIncomingActivityFromOthers({ userID }) {
yield takeEvery(({ payload, type }) => type === INCOMING_ACTIVITY && payload.activity.from.id !== userID, function*({
payload: { activity }
}) {
const shouldSpeakIncomingActivity = yield select(shouldSpeakIncomingActivitySelector);
const shouldSpeak = speakableActivity(activity) && shouldSpeakIncomingActivity;
yield takeEvery(
({ payload, type }) =>
// In Direct Line, the "role" is not filled (yet), but we do know the user ID.
// In Direct Line Speech, we do not know the user ID, but "role" is filled with "bot" or "user".
// Here, we do two checks: the speakable activity must not have user ID, and must not have role === 'user'
type === INCOMING_ACTIVITY && payload.activity.from.id !== userID && payload.activity.from.role !== 'user',
function*({ payload: { activity } }) {
const shouldSpeakIncomingActivity = yield select(shouldSpeakIncomingActivitySelector);
const shouldSpeak = speakableActivity(activity) && shouldSpeakIncomingActivity;

if (
shouldSpeak &&
(activity.speak ||
activity.text ||
~(activity.attachments || []).findIndex(({ content: { speak } = {} }) => speak))
) {
yield put(markActivity(activity, 'speak', true));
}
if (
shouldSpeak &&
(activity.speak ||
activity.text ||
~(activity.attachments || []).findIndex(({ content: { speak } = {} }) => speak))
) {
yield put(markActivity(activity, 'speak', true));
}

if (shouldSpeak && activity.inputHint === 'expectingInput') {
yield put(setDictateState(WILL_START));
} else if (activity.inputHint === 'ignoringInput') {
yield put(stopDictate());
if (shouldSpeak && activity.inputHint === 'expectingInput') {
yield put(setDictateState(WILL_START));
} else if (activity.inputHint === 'ignoringInput') {
yield put(stopDictate());
}
}
});
);
}

export default function* speakActivityAndStartDictateOnIncomingActivityFromOthersSaga() {
Expand Down

0 comments on commit 50336ad

Please sign in to comment.