import {defineStore} from 'pinia'
import ImmunityApi from '@/api/ImmunityApi'
import {useUserStore} from '@/store/userStore'
import type AjaxResult from '@/mode/AjaxResult'
import type Immunity from '@/mode/Immunity'

/**
 * @description 免打扰库
 */
export const useImmunityStore = defineStore({
  id: 'immunity_store',
  state: () => ({
    immunityList: new Array<string>()
  }),
  actions: {
    loadData() {
      const userId = useUserStore().getUser()?.id
      if (userId) {
        ImmunityApi.list(userId).then((res:AjaxResult<Immunity[]>) => {
          this.immunityList = res.data.map((item) => item.chatId)
        })
      }
    }
  }
})
