-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
ConversationView.vue
102 lines (96 loc) 路 2.4 KB
/
ConversationView.vue
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<template>
<section class="app-content columns">
<chat-list
:conversation-inbox="inboxId"
:page-title="$t('CHAT_LIST.TAB_HEADING')"
>
</chat-list>
<conversation-box
:inbox-id="inboxId"
:is-contact-panel-open="isContactPanelOpen"
@contactPanelToggle="onToggleContactPanel"
>
</conversation-box>
<contact-panel
v-if="isContactPanelOpen"
:conversation-id="conversationId"
/>
</section>
</template>
<script>
/* eslint no-console: 0 */
/* global bus */
import { mapGetters } from 'vuex';
import ChatList from '../../../components/ChatList';
import ContactPanel from './ContactPanel';
import ConversationBox from '../../../components/widgets/conversation/ConversationBox';
export default {
components: {
ChatList,
ContactPanel,
ConversationBox,
},
data() {
return {
pageTitle: this.$state,
panelToggleState: false,
};
},
computed: {
...mapGetters({
chatList: 'getAllConversations',
}),
isContactPanelOpen: {
get() {
if (this.conversationId) {
return this.panelToggleState;
}
return false;
},
set(val) {
this.panelToggleState = val;
},
},
},
props: ['inboxId', 'conversationId'],
mounted() {
this.$watch('$store.state.route', () => {
switch (this.$store.state.route.name) {
case 'inbox_conversation':
this.setActiveChat();
break;
case 'inbox_dashboard':
if (this.inboxId) {
this.$store.dispatch('setActiveInbox', this.inboxId);
}
break;
case 'conversation_through_inbox':
if (this.inboxId) {
this.$store.dispatch('setActiveInbox', this.inboxId);
}
this.setActiveChat();
break;
default:
this.$store.dispatch('setActiveInbox', null);
break;
}
});
this.$watch('chatList.length', () => {
this.setActiveChat();
});
},
methods: {
setActiveChat() {
const conversationId = parseInt(this.conversationId, 10);
const [chat] = this.chatList.filter(c => c.id === conversationId);
if (!chat) return;
this.$store.dispatch('setActiveChat', chat).then(() => {
bus.$emit('scrollToMessage');
});
},
onToggleContactPanel() {
this.isContactPanelOpen = !this.isContactPanelOpen;
},
},
};
</script>