Skip to content

Commit

Permalink
feat: Typing indicator is dismissed upon message from same sender
Browse files Browse the repository at this point in the history
Verify:
 - Typing shows indicator, message send dismisses
 - bug: note that too many notifyOfTyping(active:false) are emitted due
   to mergeMap instead of switchMap
  • Loading branch information
deanrad committed Apr 7, 2017
1 parent a79b691 commit 0316213
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion imports/antares/epics.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,23 @@ export default {
.throttleTime(2000)
.map(a => Actions.Activity.notifyOfTyping({
sender: a.payload.sender
}))
})),

dismissTypingV1: action$ => {
const dismissUponMessageFromSame = notifyAction =>
action$.ofType('Message.send')
.filter(a => a.payload.sender === notifyAction.payload.sender)
.mapTo({
type: 'Activity.notifyOfTyping',
payload: {
...notifyAction.payload,
active: false
},
meta: { antares: { localOnly: true } }
})

return action$.ofType('Activity.notifyOfTyping')
.filter(a => a.payload.active === true)
.mergeMap(dismissUponMessageFromSame)
}
}

0 comments on commit 0316213

Please sign in to comment.