Skip to content

Commit

Permalink
actionTypes: Make recipients and sender exact on `EventTypingComm…
Browse files Browse the repository at this point in the history
…on`.

The doc, at https://zulip.com/api/get-events, suggests that these
types already include all fields that will be present. So, make them
exact.

An instance of zulip#3452.
  • Loading branch information
chrisbobbe committed Mar 10, 2021
1 parent 3fff26a commit 5ef5162
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/actionTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,14 @@ type EventPresenceAction = {|
type EventTypingCommon = {|
...ServerEvent,
ownUserId: UserId,
recipients: $ReadOnlyArray<{
recipients: $ReadOnlyArray<{|
user_id: UserId,
email: string,
}>,
sender: {
|}>,
sender: {|
user_id: UserId,
email: string,
},
|},
time: number,
|};

Expand Down
8 changes: 7 additions & 1 deletion src/typing/__tests__/typingReducer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ describe('typingReducer', () => {
time: number,
|}): Action => {
const { op, sender, recipients, time } = args;
const base = { id: 123, ownUserId: eg.selfUser.user_id, sender, recipients, time };
const base = {
id: 123,
ownUserId: eg.selfUser.user_id,
sender: { user_id: sender.user_id, email: sender.email },
recipients: recipients.map(r => ({ user_id: r.user_id, email: r.email })),
time,
};
return op === 'start'
? { ...base, op: 'start', type: EVENT_TYPING_START }
: { ...base, op: 'stop', type: EVENT_TYPING_STOP };
Expand Down

0 comments on commit 5ef5162

Please sign in to comment.