<commit_before>import actionTypes from '../../actionTypes'

const inititalState = {
  location: null,
  address: null,
  signTime: null,
  isSigning: null,
  remarkText: null,
  remarkURL: null
}

const receiveLocation = (state, action) => {
  return {
    ...state,
    location: action.location
  }
}

const receiveAddress = (state, action) => {
  const address = action.location.address
  return {
    ...state,
    address
  }
}

const updateCurrentTime = (state, action) => {
  return {
    ...state,
    currentTime: action.currentTime
  }
}

const postSignRecord = state => {
  return {
    ...state,
    isSigning: true
  }
}

const postSignRecordSucceed = (state, action) => {
  const result = action.result
  return {
    ...state,
    isSigning: false,
    signTime: result.signTime
  }
}

const saveWaiqinRemark = (state, action) => {
  const { remarkText, remarkURL } = action
  return {
    ...state,
    remarkText,
    remarkURL
  }
}

const waiqinReducers = (state = inititalState, action) => {
  switch(action.type) {
    case actionTypes.RECEIVE_LOCATION:
      return receiveLocation(state, action)
    case actionTypes.RECEIVE_ADDRESS:
      return receiveAddress(state, action)
    case actionTypes.UPDATE_CURRENTTIME:
      return updateCurrentTime(state, action)
    case actionTypes.POST_SIGN_RECORD:
      return postSignRecord(state)
    case actionTypes.POST_SIGN_RECORD_SUCCEED:
      return postSignRecordSucceed(state, action)
    case actionTypes.SAVE_WAIQIN_REMARK:
      return saveWaiqinRemark(state, action)
    default:
      return state
  }
}

export default waiqinReducers<commit_msg>新增历史消息队列<commit_after>import actionTypes from '../../actionTypes'

const inititalState = {
  location: null,
  address: null,
  signTime: null,
  isSigning: null,
  remarkText: null,
  remarkURL: null,
  historys: [],
  historyBy: null
}

const receiveLocation = (state, action) => {
  return {
    ...state,
    location: action.location
  }
}

const receiveAddress = (state, action) => {
  const address = action.location.address
  return {
    ...state,
    address
  }
}

const updateCurrentTime = (state, action) => {
  return {
    ...state,
    currentTime: action.currentTime
  }
}

const postSignRecord = state => {
  return {
    ...state,
    isSigning: true
  }
}

const postSignRecordSucceed = (state, action) => {
  const result = action.result
  return {
    ...state,
    isSigning: false,
    signTime: result.signTime
  }
}

const saveWaiqinRemark = (state, action) => {
  const { remarkText, remarkURL } = action
  return {
    ...state,
    remarkText,
    remarkURL
  }
}

const requestWaiqinHistory = (state, action) => {
  return {
    ...state,
    historyBy: action.userId
  }
}

const receiveWaiqinHistory = (state, action) => {
  const { userId, signRecords }  = action
  const historys = state.historys.filter(history => history.userId !== userId)
  historys.push({
    userId,
    signRecords
  })
  return {
    ...state,
    historys
  }
}

const waiqinReducers = (state = inititalState, action) => {
  switch(action.type) {
    case actionTypes.RECEIVE_LOCATION:
      return receiveLocation(state, action)
    case actionTypes.RECEIVE_ADDRESS:
      return receiveAddress(state, action)
    case actionTypes.UPDATE_CURRENTTIME:
      return updateCurrentTime(state, action)
    case actionTypes.POST_SIGN_RECORD:
      return postSignRecord(state)
    case actionTypes.POST_SIGN_RECORD_SUCCEED:
      return postSignRecordSucceed(state, action)
    case actionTypes.SAVE_WAIQIN_REMARK:
      return saveWaiqinRemark(state, action)
    case actionTypes.REQUEST_WAIQIN_HISTORY:
      return requestWaiqinHistory(state, action)
    case actionTypes.RECEIVE_WAIQIN_HISTORY:
      return receiveWaiqinHistory(state, action)
    default:
      return state
  }
}

export default waiqinReducers
{'fraction_non_alphanumeric': 0.10535900104058273, 'fraction_numerical': 0.0, 'mean_word_length': 3.2206366630076837, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2240876', 'n_tokens_mistral': 1260, 'n_tokens_neox': 1271, 'n_words': 273}