export const mutations = {
  setScatter (state, scatter) {
    state.scatter = scatter
  },
  setEos (state, eosjs) {
    state.eos = eosjs
  },
  setAccount (state, account) {
    state.account = account
  },
  setToAccount (state, name) {
    state.toAccount = name
  },
  setBalance (state, balance) {
    state.balance = balance
  },
  setMoney (state, money) {
    state.money = money
  },
  setGt (state, gt) {
    state.gt = gt
  },
  setMainnet (state, mainnet) {
    state.mainnet = mainnet
  },
  setGTError (state, count) {
    state.gtErrorCount = count
  },
  setEOSError (state, count) {
    state.eosErrorCount = count
  },
  setPublicKey (state, string) {
    state.publicKey = string
  },
  setUserId (state, string) {
    state.userId = string
  },
  setToken (state, string) {
    state.token = string
  },
  changeSessionId (state, data) {
    state.curSession = data
  },
  setUserInfo (state, data) {
    state.userInfo = data
  },
  setUserUserName (state, data) {
    state.userInfo.user_name = data
  },
  setUserNickName (state, data) {
    state.userInfo.nick_name = data
  },
  updateUserPhoto (state, data) {
    state.userInfo.cover_photo = data
  },
  setLogining (state, isLogining) {
    state.isLogining = isLogining
  },
  setCopyText (state, data) {
    state.copyText = data
  },
  /**
   * @des 更新热门群组推荐加群状态
   * @param {Number} data.groupId 群id
   * @param {Number} data.isJoin {1:加入,0退出}
  */
  changeHotGroupStatus (state, data) {
    if (state.hotList.length <= 0) return

    let index = state.hotList.findIndex((item, index) => {
      return item.group_id == data.groupId
    })

    if (index > -1) {
      state.hotList[index].is_join = data.isJoin
      // 更新人数
      data.isJoin > 0 ? ++state.hotList[index].member_num : --state.hotList[index].member_num
    }
  }
}
