Initial Commit
Co-authored-by: Subin <subinthattaparambil@gmail.com> Co-authored-by: Manoj <manojmj92@gmail.com> Co-authored-by: Nithin <webofnithin@gmail.com>
This commit is contained in:
31
app/javascript/src/mixins/conversations.js
Normal file
31
app/javascript/src/mixins/conversations.js
Normal file
@@ -0,0 +1,31 @@
|
||||
/* eslint no-console: 0 */
|
||||
/* global axios */
|
||||
/* global moment */
|
||||
/* eslint no-undef: "error" */
|
||||
/* eslint no-unused-expressions: ["error", { "allowShortCircuit": true }] */
|
||||
|
||||
export default {
|
||||
|
||||
methods: {
|
||||
lastMessage(m) {
|
||||
return m.messages.last();
|
||||
},
|
||||
unreadMessagesCount(m) {
|
||||
return m.messages.filter(chat =>
|
||||
chat.created_at * 1000 > m.agent_last_seen_at * 1000 &&
|
||||
(chat.message_type === 0 && chat.private !== true)
|
||||
).length;
|
||||
},
|
||||
readMessages(m) {
|
||||
return m.messages.filter(chat =>
|
||||
chat.created_at * 1000 <= m.agent_last_seen_at * 1000
|
||||
);
|
||||
},
|
||||
unReadMessages(m) {
|
||||
return m.messages.filter(chat =>
|
||||
chat.created_at * 1000 > m.agent_last_seen_at * 1000
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
};
|
||||
9
app/javascript/src/mixins/isAdmin.js
Normal file
9
app/javascript/src/mixins/isAdmin.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import Auth from '../api/auth';
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
isAdmin() {
|
||||
return Auth.isAdmin();
|
||||
},
|
||||
},
|
||||
};
|
||||
29
app/javascript/src/mixins/time.js
Normal file
29
app/javascript/src/mixins/time.js
Normal file
@@ -0,0 +1,29 @@
|
||||
/* eslint no-console: 0 */
|
||||
/* global axios */
|
||||
/* eslint no-undef: "error" */
|
||||
/* eslint no-unused-expressions: ["error", { "allowShortCircuit": true }] */
|
||||
import moment from 'moment';
|
||||
|
||||
export default {
|
||||
|
||||
methods: {
|
||||
messageStamp(time) {
|
||||
const createdAt = time * 1000;
|
||||
return moment(createdAt).format('h:mm A');
|
||||
},
|
||||
wootTime(time) {
|
||||
const createdAt = time * 1000;
|
||||
return moment(createdAt);
|
||||
},
|
||||
dynamicTime(time) {
|
||||
const createdAt = moment(time * 1000);
|
||||
return createdAt.calendar(null, {
|
||||
sameDay: 'h:mm A',
|
||||
lastDay: '[Yesterday]',
|
||||
lastWeek: 'ddd',
|
||||
sameElse: 'D MMM',
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user