aboutsummaryrefslogtreecommitdiff
path: root/src/components/chat_list/chat_list.js
blob: 95708d1dddce2352a637158d1167e34f1ece7aae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { mapState, mapGetters } from 'vuex'
import ChatListItem from '../chat_list_item/chat_list_item.vue'
import ChatNew from '../chat_new/chat_new.vue'
import List from '../list/list.vue'

const ChatList = {
  components: {
    ChatListItem,
    List,
    ChatNew
  },
  computed: {
    ...mapState({
      currentUser: state => state.users.currentUser
    }),
    ...mapGetters(['sortedChatList'])
  },
  data () {
    return {
      isNew: false
    }
  },
  created () {
    this.$store.dispatch('fetchChats', { latest: true })
  },
  methods: {
    cancelNewChat () {
      this.isNew = false
      this.$store.dispatch('fetchChats', { latest: true })
    },
    newChat () {
      this.isNew = true
    }
  }
}

export default ChatList