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) {
|
async sendMessage(message) {
|
||||||
try {
|
try {
|
||||||
await this.$apollo.mutate({
|
const { data: { CreateMessage: createdMessage }} = await this.$apollo.mutate({
|
||||||
mutation: createMessageMutation(),
|
mutation: createMessageMutation(),
|
||||||
variables: {
|
variables: {
|
||||||
roomId: message.roomId,
|
roomId: message.roomId,
|
||||||
@ -362,7 +362,7 @@ export default {
|
|||||||
})
|
})
|
||||||
const roomIndex = this.rooms.findIndex((r) => r.id === message.roomId)
|
const roomIndex = this.rooms.findIndex((r) => r.id === message.roomId)
|
||||||
const changedRoom = { ...this.rooms[roomIndex] }
|
const changedRoom = { ...this.rooms[roomIndex] }
|
||||||
changedRoom.lastMessage = message
|
changedRoom.lastMessage = createdMessage
|
||||||
changedRoom.lastMessage.content = changedRoom.lastMessage.content.trim().substring(0, 30)
|
changedRoom.lastMessage.content = changedRoom.lastMessage.content.trim().substring(0, 30)
|
||||||
this.rooms[roomIndex] = changedRoom
|
this.rooms[roomIndex] = changedRoom
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -4,8 +4,23 @@ export const createMessageMutation = () => {
|
|||||||
return gql`
|
return gql`
|
||||||
mutation ($roomId: ID!, $content: String!) {
|
mutation ($roomId: ID!, $content: String!) {
|
||||||
CreateMessage(roomId: $roomId, content: $content) {
|
CreateMessage(roomId: $roomId, content: $content) {
|
||||||
|
#_id
|
||||||
id
|
id
|
||||||
|
indexId
|
||||||
content
|
content
|
||||||
|
senderId
|
||||||
|
author {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
username
|
||||||
|
avatar
|
||||||
|
date
|
||||||
|
room {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
saved
|
||||||
|
distributed
|
||||||
|
seen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
@ -26,6 +41,9 @@ export const messageQuery = () => {
|
|||||||
username
|
username
|
||||||
avatar
|
avatar
|
||||||
date
|
date
|
||||||
|
room {
|
||||||
|
id
|
||||||
|
}
|
||||||
saved
|
saved
|
||||||
distributed
|
distributed
|
||||||
seen
|
seen
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user