From 06cb620211201d312f62492968bd34ffcc87c042 Mon Sep 17 00:00:00 2001 From: ilya-bkv Date: Thu, 15 Dec 2022 16:25:20 +0300 Subject: [PATCH] Temp poling messages --- src/components/Inbox/Message.tsx | 2 +- src/components/Views/Inbox.tsx | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/Inbox/Message.tsx b/src/components/Inbox/Message.tsx index 0d32c981..298ef5b1 100644 --- a/src/components/Inbox/Message.tsx +++ b/src/components/Inbox/Message.tsx @@ -55,7 +55,7 @@ const Message = (props: Props) => {
-
{formattedTime(props.content.createdAt)}
+
{formattedTime(props.content.createdAt * 1000)}
) } diff --git a/src/components/Views/Inbox.tsx b/src/components/Views/Inbox.tsx index bb9b6b60..fa8138e7 100644 --- a/src/components/Views/Inbox.tsx +++ b/src/components/Views/Inbox.tsx @@ -9,7 +9,7 @@ import MessagesFallback from '../Inbox/MessagesFallback' import QuotedMessage from '../Inbox/QuotedMessage' import { Icon } from '../_shared/Icon' import { useSession } from '../../context/session' -import { loadRecipients } from '../../stores/inbox' +import { loadMessages, loadRecipients } from '../../stores/inbox' import { t } from '../../utils/intl' import { Modal } from '../Nav/Modal' import { showModal } from '../../stores/ui' @@ -68,6 +68,20 @@ export const InboxView = () => { } } + // TODO: удалить когда будет готова подписка + createEffect(() => { + setInterval(async () => { + if (!currentDialog()) return + try { + await getMessages(currentDialog().id) + } catch (error) { + console.error('[getMessages]', error) + } finally { + chatWindow.scrollTop = chatWindow.scrollHeight + } + }, 2000) + }) + onMount(async () => { try { const response = await loadRecipients({ days: 365 })