mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
fix lastMessage to contain proper values
This commit is contained in:
parent
e419e247b6
commit
2f76d0b502
@ -353,7 +353,7 @@ export default {
|
||||
|
||||
async sendMessage(message) {
|
||||
try {
|
||||
await this.$apollo.mutate({
|
||||
const { data: { CreateMessage: createdMessage }} = await this.$apollo.mutate({
|
||||
mutation: createMessageMutation(),
|
||||
variables: {
|
||||
roomId: message.roomId,
|
||||
@ -362,7 +362,7 @@ export default {
|
||||
})
|
||||
const roomIndex = this.rooms.findIndex((r) => r.id === message.roomId)
|
||||
const changedRoom = { ...this.rooms[roomIndex] }
|
||||
changedRoom.lastMessage = message
|
||||
changedRoom.lastMessage = createdMessage
|
||||
changedRoom.lastMessage.content = changedRoom.lastMessage.content.trim().substring(0, 30)
|
||||
this.rooms[roomIndex] = changedRoom
|
||||
} catch (error) {
|
||||
|
||||
@ -4,8 +4,23 @@ export const createMessageMutation = () => {
|
||||
return gql`
|
||||
mutation ($roomId: ID!, $content: String!) {
|
||||
CreateMessage(roomId: $roomId, content: $content) {
|
||||
#_id
|
||||
id
|
||||
indexId
|
||||
content
|
||||
senderId
|
||||
author {
|
||||
id
|
||||
}
|
||||
username
|
||||
avatar
|
||||
date
|
||||
room {
|
||||
id
|
||||
}
|
||||
saved
|
||||
distributed
|
||||
seen
|
||||
}
|
||||
}
|
||||
`
|
||||
@ -26,6 +41,9 @@ export const messageQuery = () => {
|
||||
username
|
||||
avatar
|
||||
date
|
||||
room {
|
||||
id
|
||||
}
|
||||
saved
|
||||
distributed
|
||||
seen
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user