Resurrection of the broken pusher (#25)
This commit is contained in:
parent
3b26b78df0
commit
1313c50df2
5 changed files with 74 additions and 41 deletions
|
@ -56,5 +56,5 @@ window.onload = () => {
|
||||||
components: { App },
|
components: { App },
|
||||||
template: '<App/>',
|
template: '<App/>',
|
||||||
}).$mount('#app');
|
}).$mount('#app');
|
||||||
|
window.pusher = vuePusher.init();
|
||||||
};
|
};
|
||||||
window.pusher = vuePusher.init();
|
|
||||||
|
|
|
@ -1,37 +1,52 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="conversations-sidebar medium-4 columns">
|
<div class="conversations-sidebar medium-4 columns">
|
||||||
|
|
||||||
<!-- <SearchBox></SearchBox> -->
|
<!-- <SearchBox></SearchBox> -->
|
||||||
|
|
||||||
<div class="chat-list__top">
|
<div class="chat-list__top">
|
||||||
<h1 class="page-title">{{ getInboxName }}</h1>
|
<h1 class="page-title">
|
||||||
|
{{ getInboxName }}
|
||||||
|
</h1>
|
||||||
<chat-filter @statusFilterChange="getDataForStatusTab"></chat-filter>
|
<chat-filter @statusFilterChange="getDataForStatusTab"></chat-filter>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<chat-type-tabs :items="assigneeTabItems" :activeTabIndex="activeAssigneeTab" @chatTabChange="getDataForTab" class="tab--chat-type"></chat-type-tabs>
|
<chat-type-tabs
|
||||||
|
:items="assigneeTabItems"
|
||||||
|
:active-tab-index="activeAssigneeTab"
|
||||||
|
class="tab--chat-type"
|
||||||
|
@chatTabChange="getDataForTab"
|
||||||
|
></chat-type-tabs>
|
||||||
|
|
||||||
<p v-if="!chatListLoading && !getChatsForTab(activeStatusTab).length" class="content-box">
|
<p
|
||||||
|
v-if="!chatListLoading && !getChatsForTab(activeStatusTab).length"
|
||||||
|
class="content-box"
|
||||||
|
>
|
||||||
{{ $t('CHAT_LIST.LIST.404') }}
|
{{ $t('CHAT_LIST.LIST.404') }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="text-center" v-if="chatListLoading"><span class="spinner message"></span></div>
|
<div v-if="chatListLoading" class="text-center">
|
||||||
|
<span class="spinner message"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<transition-group name="conversations-list" tag="div" class="conversations-list">
|
<transition-group
|
||||||
<conversation-card v-for="chat in getChatsForTab(activeStatusTab)" :chat="chat" v-bind:key="chat"/>
|
name="conversations-list"
|
||||||
|
tag="div"
|
||||||
|
class="conversations-list"
|
||||||
|
>
|
||||||
|
<conversation-card
|
||||||
|
v-for="chat in getChatsForTab(activeStatusTab)"
|
||||||
|
:key="chat.id"
|
||||||
|
:chat="chat"
|
||||||
|
/>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
/* global axios */
|
|
||||||
/* eslint-env browser */
|
/* eslint-env browser */
|
||||||
/* eslint no-console: 0 */
|
/* eslint no-console: 0 */
|
||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
import Thumbnail from './widgets/Thumbnail';
|
|
||||||
import ChatFilter from './widgets/conversation/ChatFilter';
|
import ChatFilter from './widgets/conversation/ChatFilter';
|
||||||
import SearchBox from './widgets/SearchBox';
|
|
||||||
import ChatTypeTabs from './widgets/ChatTypeTabs';
|
import ChatTypeTabs from './widgets/ChatTypeTabs';
|
||||||
import ConversationCard from './widgets/conversation/ConversationCard';
|
import ConversationCard from './widgets/conversation/ConversationCard';
|
||||||
import timeMixin from '../mixins/time';
|
import timeMixin from '../mixins/time';
|
||||||
|
@ -39,8 +54,8 @@ import conversationMixin from '../mixins/conversations';
|
||||||
import wootConstants from '../constants';
|
import wootConstants from '../constants';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['conversationInbox', 'pageTitle'],
|
|
||||||
mixins: [timeMixin, conversationMixin],
|
mixins: [timeMixin, conversationMixin],
|
||||||
|
props: ['conversationInbox', 'pageTitle'],
|
||||||
data: () => ({
|
data: () => ({
|
||||||
chats: null,
|
chats: null,
|
||||||
activeStatusTab: 0,
|
activeStatusTab: 0,
|
||||||
|
@ -90,7 +105,9 @@ export default {
|
||||||
},
|
},
|
||||||
getInboxName() {
|
getInboxName() {
|
||||||
const inboxId = Number(this.activeInbox);
|
const inboxId = Number(this.activeInbox);
|
||||||
const [stateInbox] = this.inboxesList.filter(inbox => inbox.channel_id === inboxId);
|
const [stateInbox] = this.inboxesList.filter(
|
||||||
|
inbox => inbox.channel_id === inboxId
|
||||||
|
);
|
||||||
return !stateInbox ? this.pageTitle : stateInbox.label;
|
return !stateInbox ? this.pageTitle : stateInbox.label;
|
||||||
},
|
},
|
||||||
getToggleStatus() {
|
getToggleStatus() {
|
||||||
|
@ -101,7 +118,6 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
fetchData() {
|
fetchData() {
|
||||||
if (this.chatLists.length === 0) {
|
if (this.chatLists.length === 0) {
|
||||||
this.$store.dispatch('fetchAllConversations', {
|
this.$store.dispatch('fetchAllConversations', {
|
||||||
|
@ -127,14 +143,17 @@ export default {
|
||||||
let copyList = [];
|
let copyList = [];
|
||||||
if (this.activeAssigneeTab === wootConstants.ASSIGNEE_TYPE_SLUG.MINE) {
|
if (this.activeAssigneeTab === wootConstants.ASSIGNEE_TYPE_SLUG.MINE) {
|
||||||
copyList = this.mineChatsList.slice();
|
copyList = this.mineChatsList.slice();
|
||||||
} else if (this.activeAssigneeTab === wootConstants.ASSIGNEE_TYPE_SLUG.UNASSIGNED) {
|
} else if (
|
||||||
|
this.activeAssigneeTab === wootConstants.ASSIGNEE_TYPE_SLUG.UNASSIGNED
|
||||||
|
) {
|
||||||
copyList = this.unAssignedChatsList.slice();
|
copyList = this.unAssignedChatsList.slice();
|
||||||
} else {
|
} else {
|
||||||
copyList = this.allChatList.slice();
|
copyList = this.allChatList.slice();
|
||||||
}
|
}
|
||||||
const sorted = copyList.sort((a, b) =>
|
const sorted = copyList.sort((a, b) =>
|
||||||
this.wootTime(this.lastMessage(a).created_at)
|
this.wootTime(this.lastMessage(a).created_at).isBefore(
|
||||||
.isBefore(this.wootTime(this.lastMessage(b).created_at))
|
this.wootTime(this.lastMessage(b).created_at)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return sorted;
|
return sorted;
|
||||||
|
@ -142,8 +161,6 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
Thumbnail,
|
|
||||||
SearchBox,
|
|
||||||
ChatTypeTabs,
|
ChatTypeTabs,
|
||||||
ConversationCard,
|
ConversationCard,
|
||||||
ChatFilter,
|
ChatFilter,
|
||||||
|
|
|
@ -1,25 +1,40 @@
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<transition-group name="wizard-items" tag="div" class="wizard-box flex-child-shrink" :class="classObject">
|
<transition-group
|
||||||
<div class="item" v-for="item in items" v-bind:key="item" :class="{ active: isActive(item), over: isOver(item) }">
|
name="wizard-items"
|
||||||
<h3>{{item.title}}
|
tag="div"
|
||||||
<span class="completed" v-if="isOver(item)">
|
class="wizard-box flex-child-shrink"
|
||||||
<i class="ion-checkmark"></i>
|
:class="classObject"
|
||||||
</span>
|
>
|
||||||
</h3>
|
<div
|
||||||
<span class="step">
|
v-for="item in items"
|
||||||
{{items.indexOf(item)+1}}
|
:key="item.id"
|
||||||
|
class="item"
|
||||||
|
:class="{ active: isActive(item), over: isOver(item) }"
|
||||||
|
>
|
||||||
|
<h3>
|
||||||
|
{{ item.title }}
|
||||||
|
<span v-if="isOver(item)" class="completed">
|
||||||
|
<i class="ion-checkmark"></i>
|
||||||
</span>
|
</span>
|
||||||
<p>{{item.body}}</p>
|
</h3>
|
||||||
</div>
|
<span class="step">
|
||||||
</transition-group>
|
{{ items.indexOf(item) + 1 }}
|
||||||
|
</span>
|
||||||
|
<p>{{ item.body }}</p>
|
||||||
|
</div>
|
||||||
|
</transition-group>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
/* eslint no-console: 0 */
|
/* eslint no-console: 0 */
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
items: Array,
|
items: {
|
||||||
|
type: Array,
|
||||||
|
default() {
|
||||||
|
return [];
|
||||||
|
},
|
||||||
|
},
|
||||||
isFullwidth: Boolean,
|
isFullwidth: Boolean,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ export default {
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
inboxId: {
|
inboxId: {
|
||||||
type: String,
|
type: [Number, String],
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -27,7 +27,7 @@ class VuePusher {
|
||||||
|
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
bindEvent(channel) {
|
bindEvent(channel) {
|
||||||
channel.bind('message.created', function messageCreate(data) {
|
channel.bind('message.created', data => {
|
||||||
// Play sound if incoming
|
// Play sound if incoming
|
||||||
if (!data.message_type) {
|
if (!data.message_type) {
|
||||||
new Audio(ding).play();
|
new Audio(ding).play();
|
||||||
|
@ -35,17 +35,18 @@ class VuePusher {
|
||||||
this.app.$store.dispatch('addMessage', data);
|
this.app.$store.dispatch('addMessage', data);
|
||||||
});
|
});
|
||||||
|
|
||||||
channel.bind('conversation.created', function conversationCreated(data) {
|
channel.bind('conversation.created', data => {
|
||||||
this.app.$store.dispatch('addConversation', data);
|
this.app.$store.dispatch('addConversation', data);
|
||||||
});
|
});
|
||||||
|
|
||||||
channel.bind('status_change:conversation', function statusChange(data) {
|
channel.bind('status_change:conversation', data => {
|
||||||
this.app.$store.dispatch('addConversation', data);
|
this.app.$store.dispatch('addConversation', data);
|
||||||
});
|
});
|
||||||
|
|
||||||
channel.bind('assignee.changed', function assigneeChanged(payload) {
|
channel.bind('assignee.changed', payload => {
|
||||||
if (!payload.meta) return;
|
const { meta } = payload;
|
||||||
const { assignee } = payload.meta;
|
if (!meta) return;
|
||||||
|
const { assignee } = meta;
|
||||||
const { id } = payload;
|
const { id } = payload;
|
||||||
if (id) {
|
if (id) {
|
||||||
this.app.$store.dispatch('updateAssignee', {
|
this.app.$store.dispatch('updateAssignee', {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue