Last active
          October 27, 2017 17:54 
        
      - 
      
- 
        Save seejee/cd9a147a3511ab2225a60d3ea4c1c15b to your computer and use it in GitHub Desktop. 
    new reducer thingy
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | // action | |
| export function onContentChange(contentState) { | |
| return async (dispatch, getState) => { | |
| const { type: assignmentType, drafts } = getState().studentAssignment; | |
| const { isEnabled: isProofreadEnabled } = getState().proofread; | |
| const { hasEssayReachedMinimumLength } = getState().writingSpace; | |
| const length = draftLength(contentState); | |
| if (!hasEssayReachedMinimumLength && length >= MINIMUM_ESSAY_LENGTH_THRESHOLD) { | |
| dispatch(essayHasMetMinimumLength( | |
| assignmentType, | |
| drafts.length, | |
| isProofreadEnabled | |
| )); | |
| } | |
| }; | |
| } | |
| // reducer | |
| [ESSAY_HAS_MET_MINIMUM_LENGTH]: (state, action) => { | |
| const { assignemntType, draftLength, isProofreadEnabled} = action.payload | |
| let visibleTooltips = []; | |
| if (!isProofreadEnabled) { | |
| visibleTooltips = []; | |
| } else if (assignmentType === assignmentTypes.signalCheck && draftLength === 0) { | |
| visibleTooltips = [SIGNAL_CHECK_UNLOCKED]; | |
| } else if (assignmentType === assignmentTypes.expansionPack) { | |
| visibleTooltips = [PROOFREAD_MODE_UNLOCKED]; | |
| } | |
| return { | |
| ...state, | |
| visibleTooltips: [...state.visibleTooltips, ...visibleTooltips], | |
| hasEssayReachedMinimumLength: true, | |
| }; | |
| }, | 
  
    
      This file contains hidden or 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
    
  
  
    
  | // action | |
| export function onContentChange(contentState) { | |
| return async (dispatch, getState) => { | |
| const length = draftLength(contentState); | |
| const { hasEssayReachedMinimumLength } = getState().writingSpace; | |
| if (!hasEssayReachedMinimumLength && length >= MINIMUM_ESSAY_LENGTH_THRESHOLD) { | |
| dispatch(essayHasMetMinimumLength()); | |
| } | |
| }; | |
| } | |
| // reducer | |
| [ESSAY_HAS_MET_MINIMUM_LENGTH]: (state, action, globalState) => { | |
| const { type: assignmentType, drafts } = globalState.studentAssignment; | |
| const { isEnabled: isProofreadEnabled } = globalState.proofread; | |
| let visibleTooltips = []; | |
| if (!isProofreadEnabled) { | |
| visibleTooltips = []; | |
| } else if (assignmentType === assignmentTypes.signalCheck && drafts.length === 0) { | |
| visibleTooltips = [SIGNAL_CHECK_UNLOCKED]; | |
| } else if (assignmentType === assignmentTypes.expansionPack) { | |
| visibleTooltips = [PROOFREAD_MODE_UNLOCKED]; | |
| } | |
| return { | |
| ...state, | |
| visibleTooltips: [...state.visibleTooltips, ...visibleTooltips], | |
| hasEssayReachedMinimumLength: true, | |
| }; | |
| }, | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment