Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make state.narrows an Immutable.Map. #4187

Merged
merged 15 commits into from
Jul 21, 2020

Commits on Jul 21, 2020

  1. libdefs: Prepare to edit redux-mock-store.

    In an upcoming commit, we'll change the Dispatch type in this libdef
    to play nicely with our async redux-thunk actions. I don't see an
    easy way to give the libdef the flexibility to give different types
    depending on what middleware is used, so, we hard-code it for
    ourselves, since we know we'll be using redux-thunk for the
    foreseeable future.
    
    This means we probably can't reasonably make a PR to FlowTyped, even
    though this is (surprisingly) one of the few libraries we use that
    does have a libdef hosted by FlowTyped. Ah, well.
    
    Here, we just move the file, delete the metadata at the top, and run
    our auto-formatting.
    
    [cherry-picked from zulip#4171]
    chrisbobbe authored and gnprice committed Jul 21, 2020
    Configuration menu
    Copy the full SHA
    4ce92da View commit details
    Browse the repository at this point in the history
  2. libdefs: Copy new version of redux-mock-store libdef.

    This version [1] is marked for a higher version of Flow than we're
    using now (v0.104 and above), but there aren't any errors on our
    Flow version (v0.98). So, take it.
    
    This gets us a particular change to the Dispatch type [2] that goes
    in the right direction...until we clobber it with our own Dispatch
    that accounts for async redux-thunk actions, I suppose.
    
    Ah well, there are a few minor changes that we might like to have,
    and this is a later version, so, might as well.
    
    [1]: https://github.com/flow-typed/flow-typed/blob/c4f47bdda/definitions/npm/redux-mock-store_v1.2.x/flow_v0.104.x-/redux-mock-store_v1.2.x.js
    [2]: flow-typed/flow-typed#3803
    
    [cherry-picked from zulip#4171]
    chrisbobbe authored and gnprice committed Jul 21, 2020
    Configuration menu
    Copy the full SHA
    967ddc7 View commit details
    Browse the repository at this point in the history
  3. libdefs: Hard-code redux-thunk support into redux-mock-store.

    As foreshadowed in the preceding commits, we can't really expect a
    FlowTyped-hosted libdef to have the flexibility to give us the right
    types for Dispatch on the condition that we pass `thunk` as a piece
    of middleware.
    
    We're decidedly using `thunk`, so, hard-code support for it here by
    allowing dispatch to be called with a redux-thunk async action.
    
    We're pretty consistent with having correct types for such an
    action, so not much is lost by typing its arguments loosely as
    `Function, Function`, and from some attempts, it seems much easier
    than nailing down something exactly right.
    
    [cherry-picked from zulip#4171]
    chrisbobbe authored and gnprice committed Jul 21, 2020
    Configuration menu
    Copy the full SHA
    660de30 View commit details
    Browse the repository at this point in the history
  4. mocks: Remove __mocks__/redux-mock-store.js.

    It looks like this was added with the idea that we'd use it in more
    places than we actually have. It adds a slight bit of convenience;
    with this mock, we can avoid having to write
    `configureStore([thunk])` a bunch of times.
    
    But that's a very small amount of boilerplate.
    
    The mock doesn't seem to have any other purpose that might be part
    of a unit-testing strategy.
    
    Removing it makes it possible to use the libdef without contorting
    it more drastically than we already have.
    
    [cherry-picked from zulip#4171]
    chrisbobbe authored and gnprice committed Jul 21, 2020
    Configuration menu
    Copy the full SHA
    0e55339 View commit details
    Browse the repository at this point in the history
  5. test data: Well-type navStateWithNarrow; make more representative.

    The added fields were gleaned from a real-life example observed with
    `redux-logger`.
    
    [cherry-picked from zulip#4171]
    chrisbobbe authored and gnprice committed Jul 21, 2020
    Configuration menu
    Copy the full SHA
    bf11c24 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    03637c1 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    27e20aa View commit details
    Browse the repository at this point in the history
  8. narrowsReducer tests: Remove a test that won't type-check.

    Flow won't allow these inputs (a GlobalState of `undefined`, or an
    action of `{}`).
    chrisbobbe authored and gnprice committed Jul 21, 2020
    Configuration menu
    Copy the full SHA
    55d6461 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    4077e88 View commit details
    Browse the repository at this point in the history
  10. narrowsSelectors tests [nfc]: Remove confusing expectedState variab…

    …les.
    
    `expectedState` makes sense in tests for reducers, but not really
    for selectors. The *input* of a selector is the GlobalState, but the
    output is...whatever we want to do with that input. Sometimes we
    just pick things directly from the state; sometimes we do that and
    then nudge it around until it's in a shape we want.
    
    Also rename `anchor` to the more general `result`; I'm not really
    sure what "anchor" is meant to refer to in each of these instances.
    chrisbobbe authored and gnprice committed Jul 21, 2020
    Configuration menu
    Copy the full SHA
    5a99b21 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    3ecf445 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    cc837fb View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    7718c95 View commit details
    Browse the repository at this point in the history
  14. exampleData: Export displayRecipientFromUser.

    We'll use this in pmConversationsSelectors-test in an upcoming
    commit.
    chrisbobbe authored and gnprice committed Jul 21, 2020
    Configuration menu
    Copy the full SHA
    8aafef1 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    afd013b View commit details
    Browse the repository at this point in the history