local this = class("reddotStore", G_BaseStore)
this:importPartialClass(require(L_R.store .. "reddot.reddotAction"))
this.event = {
  reddotUpdate = "reddotUpdate"
}
this.serverDotDef = {
  Mail = 1,
  WorldExplore = 2,
  AreaNew = 3,
  AreaAnim = 4,
  DomainNew = 5,
  DomainAnim = 6,
  DailyReward = 7
}

function this:init()
  this.super.init(self)
  self._dotIds = {}
end

function this:rsp_syncData(data)
  local infos = data.infos
  if not infos then
    return
  end
  if infos.redpoints then
    for _, v in ipairs(infos.redpoints) do
      self._dotIds[v.id] = self._dotIds[v.id] or {}
      if v.sub_id then
        for kk, vv in pairs(v.sub_id) do
          self._dotIds[v.id][vv] = true
        end
      end
    end
  end
  if infos.dredpoints then
    for _, v in ipairs(infos.dredpoints) do
      if self._dotIds[v.id] and v.sub_id then
        for kk, vv in pairs(v.sub_id) do
          self._dotIds[v.id][vv] = nil
        end
      end
    end
  end
  self:call(self.event.reddotUpdate)
end

function this:hasDot(id, subId)
  subId = subId or 1
  if self._dotIds[id] then
    return self._dotIds[id][subId] and 1 or 0
  end
  return 0
end

return this
