-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send welcome event and fixes around speech sagas (#1286)
* Send join event and various fixes * Cleanup * Clean up coding style * Clean up coding style * Fix numActivitiesPosted * Clean up * Stop speak activity action will mark all as spoken * Clean up * Revisit all sagas related to dictate and speak * Clean up * Clean up * Clean up * Move send typing to another branch and clean up sample * Rename whileSpeaking to whileSpeakIncomingActivity * Rename via to method * Refactoring * Better verbiage * Remove unnecessary null-ref check * Add comment for patching * Add selectors * Prefix items with area * Fix missing activities * Sort line * Send join event on connect * Move user ID check out of speakableActivity * Fix sendEvent * Update sample number
- Loading branch information
Showing
50 changed files
with
607 additions
and
335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const SEND_EVENT = 'WEB_CHAT/SEND_EVENT'; | ||
|
||
export default function sendEvent(name, value) { | ||
return { | ||
type: SEND_EVENT, | ||
payload: { name, value } | ||
}; | ||
} | ||
|
||
export { SEND_EVENT } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default activity => activity && activity.from.role === 'bot' |
3 changes: 1 addition & 2 deletions
3
...src/sagas/definition/speakableActivity.js → ...core/src/definitions/speakableActivity.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
export default function (activity, userID) { | ||
export default function (activity) { | ||
return ( | ||
activity | ||
&& activity.from | ||
&& activity.from.id !== userID | ||
&& activity.type === 'message' | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function (activity) { | ||
return activity.channelData && activity.channelData.speak; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 18 additions & 8 deletions
26
packages/core/src/sagas/clearSuggestedActionsOnPostActivitySaga.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,27 @@ | ||
import { | ||
put, | ||
take | ||
takeEvery | ||
} from 'redux-saga/effects'; | ||
|
||
import { POST_ACTIVITY_PENDING } from '../actions/postActivity'; | ||
import whileConnected from './effects/whileConnected'; | ||
|
||
import { POST_ACTIVITY_PENDING } from '../actions/postActivity'; | ||
import setSuggestedActions from '../actions/setSuggestedActions'; | ||
|
||
export default function* () { | ||
yield whileConnected(function* () { | ||
for (;;) { | ||
yield take(({ payload, type }) => type === POST_ACTIVITY_PENDING && payload.activity.type === 'message'); | ||
yield put(setSuggestedActions()); | ||
} | ||
}); | ||
yield whileConnected(clearSuggestedActionsOnPostActivity); | ||
} | ||
|
||
function* clearSuggestedActionsOnPostActivity() { | ||
yield takeEvery( | ||
({ payload, type }) => ( | ||
type === POST_ACTIVITY_PENDING | ||
&& payload.activity.type === 'message' | ||
), | ||
clearSuggestedActions | ||
); | ||
} | ||
|
||
function* clearSuggestedActions() { | ||
yield put(setSuggestedActions()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/core/src/sagas/effects/whileSpeakIncomingActivity.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { | ||
call, | ||
cancel, | ||
fork, | ||
take | ||
} from 'redux-saga/effects'; | ||
|
||
import { START_SPEAKING_ACTIVITY } from '../../actions/startSpeakingActivity'; | ||
import { STOP_SPEAKING_ACTIVITY } from '../../actions/stopSpeakingActivity'; | ||
|
||
export default function (fn) { | ||
return call(function* () { | ||
for (;;) { | ||
yield take(START_SPEAKING_ACTIVITY); | ||
|
||
const task = yield fork(fn); | ||
|
||
yield take(STOP_SPEAKING_ACTIVITY); | ||
yield cancel(task); | ||
} | ||
}); | ||
} |
Oops, something went wrong.