Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(webapp): fix lastMessage to contain proper values #6615

Merged
merged 3 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions webapp/components/Chat/Chat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,9 @@ export default {

async sendMessage(message) {
try {
await this.$apollo.mutate({
const {
data: { CreateMessage: createdMessage },
} = await this.$apollo.mutate({
mutation: createMessageMutation(),
variables: {
roomId: message.roomId,
Expand All @@ -362,7 +364,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) {
Expand Down
18 changes: 18 additions & 0 deletions webapp/graphql/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
`
Expand All @@ -26,6 +41,9 @@ export const messageQuery = () => {
username
avatar
date
room {
id
}
saved
distributed
seen
Expand Down