import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useIMStore = defineStore('IM', 
  () => {
    const uid = ref('')
    const connected = ref(false)

    const newMsg = ref(0)
    const fromChannel = ref('')
    const unreadCount = ref(0)

    const setConnected = (val) => {
      connected.value = val
    }
    const setUid = (val) => {
      uid.value = val
    }
    const setNewMsg = (val) => {
      newMsg.value = val
    }
    const setFromChannel = (val) => {
      fromChannel.value = val
    }
    const setUnreadCount = (val) => {
      unreadCount.value = val
    }
    return {
      connected,
      uid,
      newMsg,
      fromChannel,
      unreadCount,
      setUnreadCount,
      setFromChannel,
      setNewMsg,
      setUid,
      setConnected
    }
})