14 lines
532 B
JavaScript
14 lines
532 B
JavaScript
import { useConversationStore } from "@/stores/conversation"
|
|
|
|
export const messageHandler = (msg) => {
|
|
const conversationStore = useConversationStore();
|
|
const conversation = conversationStore.conversations.find(x => x.targetId == msg.senderId || x.targetId == msg.receiverId);
|
|
conversation.lastMessage = msg.content;
|
|
if (conversation.targetId == msg.receiverId) {
|
|
conversation.unreadCount = 0;
|
|
} else {
|
|
conversation.unreadCount += 1;
|
|
}
|
|
conversation.dateTime = new Date().toISOString();
|
|
|
|
} |