@@ -20,7 +20,7 @@ import CompressedAsyncStorage from '../storage/CompressedAsyncStorage';
2020import createMigration from '../redux-persist-migrate/index' ;
2121import { getGlobalSession , getGlobalSettings } from '../directSelectors' ;
2222import { migrations } from '../storage/migrations' ;
23- import type { GlobalThunkExtras } from '../reduxTypes' ;
23+ import type { Dispatch , GlobalThunkExtras } from '../reduxTypes' ;
2424
2525if ( process . env . NODE_ENV === 'development' ) {
2626 // Chrome dev tools for Immutable.
@@ -73,17 +73,29 @@ export const cacheKeys: $ReadOnlyArray<$Keys<GlobalState>> = [
7373 'realm' , 'streams' , 'subscriptions' , 'unread' , 'userGroups' , 'users' ,
7474] ;
7575
76+ /* eslint-disable no-use-before-define */
77+
7678const thunkExtras : $Exact < ThunkExtras > = {
77- // eslint-disable-next-line no-use-before-define
7879 getGlobalSession : ( ) = > getGlobalSession ( store . getState ( ) ) ,
79-
80- // eslint-disable-next-line no-use-before-define
8180 getGlobalSettings : ( ) => getGlobalSettings ( store . getState ( ) ) ,
8281} ;
8382
84- const globalThunkExtras: $Exact< GlobalThunkExtras > = Object.freeze({
85- // TODO add things
86- } );
83+ const globalThunkExtras: $Exact< GlobalThunkExtras > = {
84+ // $FlowFixMe[escaped-generic]
85+ // $FlowFixMe[incompatible-type]
86+ /* $FlowFixMe[incompatible-cast]
87+ The `store` type isn't complete: in particular it ignores thunk actions.
88+
89+ We're also using here the fact that the one function `store.dispatch`
90+ secretly plays both the role of our `GlobalDispatch` type and our
91+ `Dispatch` type... and that in the latter role, the PerAccountState
92+ that it acts on is the one belonging to the active account.
93+
94+ TODO(#5006): We'll have to add more logic here when per-account and
95+ global state become distinct.
96+ */
97+ activeAccountDispatch : action => ( store . dispatch : Dispatch ) ( action ) ,
98+ } ;
8799
88100const combinedThunkExtras: ThunkExtras & GlobalThunkExtras = {
89101 ...thunkExtras ,
0 commit comments