export default {
  setRefreshValue(refreshMap, {tableName, type, value}) {
    if (!refreshMap || !tableName || !type) {
      return refreshMap
    }
    const obj = {
      time: 0
    }
    if (refreshMap[tableName]) {
      obj['time'] = refreshMap[tableName]['time'] + 1
    }
    obj['type'] = type
    obj['value'] = value
    refreshMap[tableName] = obj

    return {...refreshMap}
  },
  getRefreshValue(refreshMap, {tableName, refreshObj}) {
    if (refreshMap && tableName) {
      const time = refreshMap[tableName] ? refreshMap[tableName].time : undefined
      if (refreshObj !== undefined && refreshObj.time !== time || refreshObj === undefined && time !== undefined) {
        return refreshMap[tableName]
      }
    }
    return refreshObj
  }
}
