@@ -20,7 +20,7 @@ import CompressedAsyncStorage from '../storage/CompressedAsyncStorage';
20
20
import createMigration from '../redux-persist-migrate/index' ;
21
21
import { getGlobalSession , getGlobalSettings } from '../directSelectors' ;
22
22
import { migrations } from '../storage/migrations' ;
23
- import type { GlobalThunkExtras } from '../reduxTypes' ;
23
+ import type { Dispatch , GlobalThunkExtras } from '../reduxTypes' ;
24
24
25
25
if ( process . env . NODE_ENV === 'development' ) {
26
26
// Chrome dev tools for Immutable.
@@ -73,17 +73,29 @@ export const cacheKeys: $ReadOnlyArray<$Keys<GlobalState>> = [
73
73
'realm' , 'streams' , 'subscriptions' , 'unread' , 'userGroups' , 'users' ,
74
74
] ;
75
75
76
+ /* eslint-disable no-use-before-define */
77
+
76
78
const thunkExtras : $Exact < ThunkExtras > = {
77
- // eslint-disable-next-line no-use-before-define
78
79
getGlobalSession : ( ) = > getGlobalSession ( store . getState ( ) ) ,
79
-
80
- // eslint-disable-next-line no-use-before-define
81
80
getGlobalSettings : ( ) => getGlobalSettings ( store . getState ( ) ) ,
82
81
} ;
83
82
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
+ } ;
87
99
88
100
const combinedThunkExtras: ThunkExtras & GlobalThunkExtras = {
89
101
...thunkExtras ,
0 commit comments