mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 03:57:52 +00:00
feat: Add pending message on dashboard (#1547)
This commit is contained in:
committed by
GitHub
parent
3e61ea5cfa
commit
7c62d3629c
@@ -1,5 +1,8 @@
|
||||
/* eslint no-console: 0 */
|
||||
/* eslint no-param-reassign: 0 */
|
||||
|
||||
import getUuid from 'widget/helpers/uuid';
|
||||
import { MESSAGE_STATUS, MESSAGE_TYPE } from 'shared/constants/messages';
|
||||
|
||||
export default () => {
|
||||
if (!Array.prototype.last) {
|
||||
Object.assign(Array.prototype, {
|
||||
@@ -26,3 +29,41 @@ export const getTypingUsersText = (users = []) => {
|
||||
const rest = users.length - 1;
|
||||
return `${user.name} and ${rest} others are typing`;
|
||||
};
|
||||
|
||||
export const createPendingMessage = data => {
|
||||
const timestamp = Math.floor(new Date().getTime() / 1000);
|
||||
const tempMessageId = getUuid();
|
||||
const pendingMessage = {
|
||||
...data,
|
||||
content: data.message,
|
||||
id: tempMessageId,
|
||||
echo_id: tempMessageId,
|
||||
status: MESSAGE_STATUS.PROGRESS,
|
||||
created_at: timestamp,
|
||||
message_type: MESSAGE_TYPE.OUTGOING,
|
||||
conversation_id: data.conversationId,
|
||||
};
|
||||
return pendingMessage;
|
||||
};
|
||||
|
||||
export const createPendingAttachment = data => {
|
||||
const [conversationId, { isPrivate = false }] = data;
|
||||
const timestamp = Math.floor(new Date().getTime() / 1000);
|
||||
const tempMessageId = getUuid();
|
||||
const pendingMessage = {
|
||||
id: tempMessageId,
|
||||
echo_id: tempMessageId,
|
||||
status: MESSAGE_STATUS.PROGRESS,
|
||||
created_at: timestamp,
|
||||
message_type: MESSAGE_TYPE.OUTGOING,
|
||||
conversation_id: conversationId,
|
||||
attachments: [
|
||||
{
|
||||
id: tempMessageId,
|
||||
},
|
||||
],
|
||||
private: isPrivate,
|
||||
content: null,
|
||||
};
|
||||
return pendingMessage;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user