-
-
Notifications
You must be signed in to change notification settings - Fork 665
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
redux types: Mark most selectors as per-account vs. global
After this change, the bulk of our selectors are correctly marked as per-account, taking a PerAccountState -- which is most of them -- or global, taking a GlobalState. The major class of exceptions is the `state.accounts` selectors found in `accountsSelectors`, as discussed in a previous commit. A more boring class of exceptions is the many small anonymous selectors (mostly as callbacks to `useSelector`) that get bits of the settings and session data. Many of those are really per-account, but for now we leave them all marked as global. At this stage none of our thunk actions or React components get converted. That means they're all still acting on GlobalState; which is why it's very convenient that (for the next while) we've set up PerAccountState so that it's a supertype of GlobalState, and a value of the latter can be freely implicitly used as the former. (Of all the Redux-related names we'll be splitting, this one is unusual in requiring renames through the per-account majority of the app code. Most will be like Selector in that the existing name is short and generic and we'll keep that for the per-account majority to use. GlobalState is the main exception, because the existing name is explicitly "global".) This doesn't yet have any real effect, because PerAccountState is for the moment just an alias of GlobalState. The real test that we've assigned each of these to the proper column will be that Flow passes when we make those two types distinct, coming soon.
- Loading branch information
Showing
10 changed files
with
65 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
/* @flow strict-local */ | ||
import type { Fetching, GlobalState, Narrow } from '../types'; | ||
import type { Fetching, PerAccountState, Narrow } from '../types'; | ||
import { getFetching } from '../directSelectors'; | ||
import { keyFromNarrow } from '../utils/narrow'; | ||
|
||
/** The value implicitly represented by a missing entry in FetchingState. */ | ||
export const DEFAULT_FETCHING = { older: false, newer: false }; | ||
|
||
export const getFetchingForNarrow = (state: GlobalState, narrow: Narrow): Fetching => | ||
export const getFetchingForNarrow = (state: PerAccountState, narrow: Narrow): Fetching => | ||
getFetching(state)[keyFromNarrow(narrow)] || DEFAULT_FETCHING; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* @flow strict-local */ | ||
import type { Narrow, GlobalState } from '../types'; | ||
import type { Narrow, PerAccountState } from '../types'; | ||
import { keyFromNarrow } from '../utils/narrow'; | ||
|
||
export const getDraftForNarrow = (state: GlobalState, narrow: Narrow): string => | ||
export const getDraftForNarrow = (state: PerAccountState, narrow: Narrow): string => | ||
state.drafts[keyFromNarrow(narrow)] || ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters