@ -32,12 +32,6 @@ const newImportListExclusion = {
tmdbId : 0 ,
} ;
interface EditImportListExclusionModalContentProps {
id? : number ;
onModalClose : ( ) = > void ;
onDeleteImportListExclusionPress ? : ( ) = > void ;
}
function createImportListExclusionSelector ( id? : number ) {
return createSelector (
( state : AppState ) = > state . settings . importListExclusions ,
@ -63,12 +57,24 @@ function createImportListExclusionSelector(id?: number) {
) ;
}
function EditImportListExclusionModalContent (
props : EditImportListExclusionModalContentProps
) {
const { id , onModalClose , onDeleteImportListExclusionPress } = props ;
interface EditImportListExclusionModalContentProps {
id? : number ;
onModalClose : ( ) = > void ;
onDeleteImportListExclusionPress ? : ( ) = > void ;
}
function EditImportListExclusionModalContent ( {
id ,
onModalClose ,
onDeleteImportListExclusionPress ,
} : EditImportListExclusionModalContentProps ) {
const { isFetching , isSaving , item , error , saveError , . . . otherProps } =
useSelector ( createImportListExclusionSelector ( id ) ) ;
const { movieTitle , movieYear , tmdbId } = item ;
const dispatch = useDispatch ( ) ;
const previousIsSaving = usePrevious ( isSaving ) ;
const dispatchSetImportListExclusionValue = ( payload : {
name : string ;
@ -78,20 +84,10 @@ function EditImportListExclusionModalContent(
dispatch ( setImportListExclusionValue ( payload ) ) ;
} ;
const { isFetching , isSaving , item , error , saveError , . . . otherProps } =
useSelector ( createImportListExclusionSelector ( props . id ) ) ;
const previousIsSaving = usePrevious ( isSaving ) ;
const { movieTitle , movieYear , tmdbId } = item ;
useEffect ( ( ) = > {
if ( ! id ) {
Object . keys ( newImportListExclusion ) . forEach ( ( name ) = > {
dispatchSetImportListExclusionValue ( {
name ,
value :
newImportListExclusion [ name as keyof typeof newImportListExclusion ] ,
} ) ;
Object . entries ( newImportListExclusion ) . forEach ( ( [ name , value ] ) = > {
dispatchSetImportListExclusionValue ( { name , value } ) ;
} ) ;
}
// eslint-disable-next-line react-hooks/exhaustive-deps
@ -101,7 +97,7 @@ function EditImportListExclusionModalContent(
if ( previousIsSaving && ! isSaving && ! saveError ) {
onModalClose ( ) ;
}
} );
} , [ previousIsSaving , isSaving , saveError , onModalClose ] );
const onSavePress = useCallback ( ( ) = > {
dispatch ( saveImportListExclusion ( { id } ) ) ;