aboutsummaryrefslogtreecommitdiff
path: root/src/services/chat_utils/chat_utils.js
diff options
context:
space:
mode:
authorShpuld Shpludson <shp@cock.li>2020-11-02 05:36:42 +0000
committerShpuld Shpludson <shp@cock.li>2020-11-02 05:36:42 +0000
commit5254fdba75fc8d645c2235902a39b79c45f9aa6f (patch)
treeac329a5fc0448d804d5aa8d77e137b00e64a4491 /src/services/chat_utils/chat_utils.js
parent590f8e17544969b1fc2456b3724e85b16cf81bdd (diff)
parent78e5a639228ba846e38ae722590aec1310275c79 (diff)
Merge branch 'optimistic-chat-posting' into 'develop'
Optimistic / nonblocking message posting for chats See merge request pleroma/pleroma-fe!1228
Diffstat (limited to 'src/services/chat_utils/chat_utils.js')
-rw-r--r--src/services/chat_utils/chat_utils.js21
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
+}