diff options
| author | eugenijm <eugenijm@protonmail.com> | 2020-10-29 13:33:06 +0300 |
|---|---|---|
| committer | eugenijm <eugenijm@protonmail.com> | 2020-11-01 23:36:58 +0300 |
| commit | e798e9a4177f025dda2b40d109fa40c2ebfd814e (patch) | |
| tree | e9916a0cf615fbff6cc5296494476cea89ac7996 /src/services/chat_utils/chat_utils.js | |
| parent | 148789767a28a988751af9635cd53fe6d85a4c75 (diff) | |
Optimistic message sending for chat
Diffstat (limited to 'src/services/chat_utils/chat_utils.js')
| -rw-r--r-- | src/services/chat_utils/chat_utils.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/services/chat_utils/chat_utils.js b/src/services/chat_utils/chat_utils.js index 86fe1af9..de6e0625 100644 --- a/src/services/chat_utils/chat_utils.js +++ b/src/services/chat_utils/chat_utils.js @@ -18,3 +18,24 @@ export const maybeShowChatNotification = (store, chat) => { showDesktopNotification(store.rootState, opts) } + +export const buildFakeMessage = ({ content, chatId, attachments, userId, idempotencyKey }) => { + const fakeMessage = { + content, + chat_id: chatId, + created_at: new Date(), + id: `${new Date().getTime()}`, + attachments: attachments, + account_id: userId, + idempotency_key: idempotencyKey, + emojis: [], + pending: true, + isNormalized: true + } + + if (attachments[0]) { + fakeMessage.attachment = attachments[0] + } + + return fakeMessage +} |
