Temp poling messages

This commit is contained in:
ilya-bkv 2022-12-15 16:25:20 +03:00
parent 94f14d101d
commit 06cb620211
2 changed files with 16 additions and 2 deletions

View File

@ -55,7 +55,7 @@ const Message = (props: Props) => {
<div innerHTML={md.render(props.content.body)} /> <div innerHTML={md.render(props.content.body)} />
</div> </div>
</div> </div>
<div class={styles.time}>{formattedTime(props.content.createdAt)}</div> <div class={styles.time}>{formattedTime(props.content.createdAt * 1000)}</div>
</div> </div>
) )
} }

View File

@ -9,7 +9,7 @@ import MessagesFallback from '../Inbox/MessagesFallback'
import QuotedMessage from '../Inbox/QuotedMessage' import QuotedMessage from '../Inbox/QuotedMessage'
import { Icon } from '../_shared/Icon' import { Icon } from '../_shared/Icon'
import { useSession } from '../../context/session' import { useSession } from '../../context/session'
import { loadRecipients } from '../../stores/inbox' import { loadMessages, loadRecipients } from '../../stores/inbox'
import { t } from '../../utils/intl' import { t } from '../../utils/intl'
import { Modal } from '../Nav/Modal' import { Modal } from '../Nav/Modal'
import { showModal } from '../../stores/ui' 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 () => { onMount(async () => {
try { try {
const response = await loadRecipients({ days: 365 }) const response = await loadRecipients({ days: 365 })