-
Notifications
You must be signed in to change notification settings - Fork 197
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
Bump the redux group with 3 updates #6003
Changes from all commits
cf8eccb
1a5904f
79fa68d
ab4cbf4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* The drafts store provides temporary storage for unsaved edits to new or | ||
* existing annotations. | ||
*/ | ||
import type { Dispatch } from 'redux'; | ||
import type { ThunkDispatch } from 'redux-thunk'; | ||
import { createSelector } from 'reselect'; | ||
|
||
import type { Annotation } from '../../../types/api'; | ||
|
@@ -105,7 +105,10 @@ function createDraft(annotation: AnnotationID, changes: DraftChanges) { | |
* An empty draft has no text and no reference tags. | ||
*/ | ||
function deleteNewAndEmptyDrafts() { | ||
return (dispatch: Dispatch, getState: () => { drafts: State }) => { | ||
return ( | ||
dispatch: ThunkDispatch<{ drafts: State }, void, any>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The I could not define an action type that didn't make one of the For references, this is /**
* The dispatch method as modified by React-Thunk; overloaded so that you can
* dispatch:
* - standard (object) actions: `dispatch()` returns the action itself
* - thunk actions: `dispatch()` returns the thunk's return value
*
* @template State The redux state
* @template ExtraThunkArg The extra argument passed to the inner function of
* thunks (if specified when setting up the Thunk middleware)
* @template BasicAction The (non-thunk) actions that can be dispatched.
*/
interface ThunkDispatch<State, ExtraThunkArg, BasicAction extends Action> {
/** Accepts a thunk function, runs it, and returns whatever the thunk itself returns */
<ReturnType>(thunkAction: ThunkAction<ReturnType, State, ExtraThunkArg, BasicAction>): ReturnType;
/** Accepts a standard action object, and returns that action object */
<Action extends BasicAction>(action: Action): Action;
/** A union of the other two overloads for TS inference purposes */
<ReturnType, Action extends BasicAction>(action: Action | ThunkAction<ReturnType, State, ExtraThunkArg, BasicAction>): Action | ReturnType;
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is pragmatic for now. |
||
getState: () => { drafts: State }, | ||
) => { | ||
const newDrafts = getState().drafts.drafts.filter(draft => { | ||
return ( | ||
!draft.annotation.id && | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
import { | ||
createSelector, | ||
createSelectorCreator, | ||
defaultMemoize, | ||
} from 'reselect'; | ||
import { createSelector, createSelectorCreator, lruMemoize } from 'reselect'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
import shallowEqual from 'shallowequal'; | ||
|
||
import type { | ||
|
@@ -197,7 +193,7 @@ function searchUrisForFrame(frame: Frame): string[] { | |
|
||
// "selector creator" that uses `shallowEqual` instead of `===` for memoization | ||
const createShallowEqualSelector = createSelectorCreator( | ||
defaultMemoize, | ||
lruMemoize, | ||
shallowEqual, | ||
); | ||
|
||
|
@@ -212,6 +208,19 @@ const searchUris = createShallowEqualSelector( | |
[], | ||
), | ||
uris => uris, | ||
{ | ||
// This selector does the actual work in its "input" functions and then | ||
// relies on Reselect not to call the identity result function if the | ||
// result of the input function is value-equal to the previous result. | ||
// | ||
// This is not really how Reselect is supposed to be used, but it works. | ||
// | ||
// What we want to achieve is that the output doesn't change if the result | ||
// is value-equal to the previous result (ie. the `state.frames` might | ||
// have changed, but if the search URL array produced from them hasn't | ||
// changed, the output reference should stay the same). | ||
devModeChecks: { identityFunctionCheck: 'never' }, | ||
}, | ||
); | ||
|
||
function getContentInfo(state: State) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the
thunk
named export now has the right types andredux-thunk/extend-redux
is no longer needed (in fact it is no longer included)