wip
This commit is contained in:
@@ -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 }
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user