Skip to content

feat: added logic to unseen.js to handle unseen messages in video-call chats [WTEL-8866](https://webitel.atlassian.net/browse/WTEL-8866) - #1598

Open
plnnsimon wants to merge 3 commits into
mainfrom
feat/WTEL-8866/chat-messages-count
Open

plnnsimon wants to merge 3 commits into
mainfrom
feat/WTEL-8866/chat-messages-count

Conversation

@plnnsimon

Copy link
Copy Markdown
Contributor

Comment on lines +196 to +225
/**
* @author OleksandrPalonnyi
*
* the video-call chat's messages arrive by mutating the SDK Conversation
* instance directly — there's no WS event to hook, so new messages are
* detected the same way useChatScroll does: by watching message count
*
* [WTEL-8866](https://webitel.atlassian.net/browse/WTEL-8866)
* */
watch(videoCallChatMessages, (messages, prevMessages) => {
const isNewMessage = messages?.length - (prevMessages?.length ?? 0) === 1;
if (!isNewMessage || isOnChat.value) return;

const lastMessage = messages.at(-1);
if (lastMessage?.member?.self) return;

store.commit('features/chat/unseen/ADD_UNSEEN_CHAT', videoCallChat.value);
});

watch(isOnChat, (isActive) => {
if (isActive) {
store.dispatch('features/chat/unseen/MARK_CHAT_SEEN', videoCallChat.value);
}
});

watch(videoCallChat, (chat, prevChat) => {
if (!chat && prevChat) {
store.commit('features/chat/unseen/REMOVE_UNSEEN_CHAT', prevChat);
}
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а не хо це винести в окремий компоузабл (або декілька) щоб інкапсулювати від колл-хедера функціонал відеодзвінка і непрочитаних?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants