direct_conversations_timeline.js (1490B)
1 import DirectConversationTimelineItem from '../direct_conversation_timeline_item/direct_conversation_timeline_item.vue' 2 import DirectConversationNew from '../direct_conversation_new/direct_conversation_new.vue' 3 import List from '../list/list.vue' 4 import withLoadMore from '../../hocs/with_load_more/with_load_more' 5 6 const DirectConversationList = withLoadMore({ 7 fetch: (props, $store) => $store.dispatch('fetchDirectConversations'), 8 select: (props, $store) => $store.state.directConversations.directConversations.data, 9 destroy: (props, $store) => undefined, 10 childPropName: 'items' 11 })(List) 12 13 const DirectConversationsTimeline = { 14 components: { 15 DirectConversationTimelineItem, 16 DirectConversationList, 17 DirectConversationNew 18 }, 19 computed: { 20 currentUser () { 21 return this.$store.state.users.currentUser 22 } 23 }, 24 data () { 25 return { 26 isNew: false 27 } 28 }, 29 created () { 30 this.$store.dispatch('fetchDirectConversations', { reset: true }) 31 }, 32 methods: { 33 cancelNewDirectConversation () { 34 this.isNew = false 35 this.$store.dispatch('fetchDirectConversations', { reset: true }) 36 }, 37 newDirectConversation () { 38 this.isNew = true 39 }, 40 readAll () { 41 this.$store.state.api.backendInteractor.readAllDirectConversations().then(() => { 42 this.$store.dispatch('markAllDirectConversationsAsRead') 43 this.$store.dispatch('refreshCurrentUser') 44 }) 45 } 46 } 47 } 48 49 export default DirectConversationsTimeline