This commit is contained in:
2026-03-20 09:56:14 +03:00
parent bc704b03cd
commit 09028e0ced
10 changed files with 76 additions and 57 deletions

View File

@@ -10,6 +10,7 @@ export interface Chat {
name: string
users: User[]
message?: Message
image?: string
}
export const useChatsStore = defineStore('chats', () => {
@@ -18,6 +19,8 @@ export const useChatsStore = defineStore('chats', () => {
const selected = ref<string[]>([])
const selectedChat = computed(() => {
if (!selected.value.length) return
return chats.value.find((chat: Chat) => chat.id === selected.value[0])
})
@@ -35,5 +38,9 @@ export const useChatsStore = defineStore('chats', () => {
}
}
function getChatLastMessage(chat: Chat) {
return chats.value.find((el) => el.id === chat.id)
}
return { chats, selected, selectedChat, getChatInfo }
})