Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modelTypes: Split
Message.stream_id
into PmMessage
and `StreamMes…
…sage`. In fact, just leave it out of `PmMessage` because it's absent on PMs, as the comment says. Flow gives us one substantive bit of feedback and one kind of false alarm: - We shouldn't be putting a `stream_id` on PMs in exampleData; so, stop doing that. - When we start putting things together to call `addItemsToStreamArray`, we need to be sure `action.message` is a stream message. We were already sure of that; there's already an early return on `action.message.type !== stream`. But that early return needs to be just a bit later in order to satisfy Flow that `action.message` can't be a stream message. In particular, as Greg explains [1], """ Specifically what's happening is: we check `action.message.type`, but then we call `getOwnUserId` -- and that's some function that might go and do anything. So in particular it might go and mutate the same object that we're looking at as `action.message`. So that object *had* had a `type` of `'private'`, but now it might not and so it might not have a `stream_id`. """ [1] zulip#4506 (comment) In particular, Flow sees the `getOwnUserId` call, and that's some function that might go and do anything -- including But Flow seems to think it's done too early, and that something in the intervening code might thwart the job it's doing. So, move that early return a bit later.
- Loading branch information