From 03162130567e123c85ab1382cd776393bc2372bb Mon Sep 17 00:00:00 2001 From: Dean Radcliffe Date: Thu, 6 Apr 2017 20:29:31 -0500 Subject: [PATCH] feat: Typing indicator is dismissed upon message from same sender Verify: - Typing shows indicator, message send dismisses - bug: note that too many notifyOfTyping(active:false) are emitted due to mergeMap instead of switchMap --- imports/antares/epics.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/imports/antares/epics.js b/imports/antares/epics.js index 5e502ac..ce63dcc 100644 --- a/imports/antares/epics.js +++ b/imports/antares/epics.js @@ -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) + } }