This commit is contained in:
Ulf Gebhardt 2023-07-18 10:54:27 +02:00
parent ae2d6c7ad5
commit 33ecc4764e
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
2 changed files with 12 additions and 8 deletions

View File

@ -61,7 +61,12 @@
<script>
import { roomQuery, createRoom, unreadRoomsQuery } from '~/graphql/Rooms'
import { messageQuery, createMessageMutation, chatMessageAdded, markMessagesAsSeen } from '~/graphql/Messages'
import {
messageQuery,
createMessageMutation,
chatMessageAdded,
markMessagesAsSeen,
} from '~/graphql/Messages'
import chatStyle from '~/constants/chat.js'
import { mapGetters, mapMutations } from 'vuex'
@ -180,11 +185,10 @@ export default {
observer.subscribe({
next: this.chatMessageAdded,
error (error) {
console.error(error)
error(error) {
this.$toast.error(error)
},
})
},
computed: {
...mapGetters({
@ -313,9 +317,9 @@ export default {
}
},
async chatMessageAdded({data}){
if(data.chatMessageAdded.room.id === this.selectedRoom?.id){
this.fetchMessages({ room: this.selectedRoom, options: { refetch: true }})
async chatMessageAdded({ data }) {
if (data.chatMessageAdded.room.id === this.selectedRoom?.id) {
this.fetchMessages({ room: this.selectedRoom, options: { refetch: true } })
} else {
// TODO this might be optimized selectively (first page vs rest)
this.rooms = []

View File

@ -37,7 +37,7 @@ export const createMessageMutation = () => {
export const chatMessageAdded = () => {
return gql`
subscription chatMessageAdded($userId: ID!) {
chatMessageAdded(userId: $userId){
chatMessageAdded(userId: $userId) {
#_id
id
# indexId