mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Merge branch 'master' into chat-notifications
This commit is contained in:
commit
deb8394fe2
@ -19,7 +19,12 @@ type Room {
|
|||||||
|
|
||||||
roomId: String! @cypher(statement: "RETURN this.id")
|
roomId: String! @cypher(statement: "RETURN this.id")
|
||||||
roomName: String! @cypher(statement: "MATCH (this)<-[:CHATS_IN]-(user:User) WHERE NOT user.id = $cypherParams.currentUserId RETURN user.name")
|
roomName: String! @cypher(statement: "MATCH (this)<-[:CHATS_IN]-(user:User) WHERE NOT user.id = $cypherParams.currentUserId RETURN user.name")
|
||||||
avatar: String! @cypher(statement: "MATCH (this)<-[:CHATS_IN]-(user:User) WHERE NOT user.id = $cypherParams.currentUserId RETURN user.avatar.url")
|
avatar: String @cypher(statement: """
|
||||||
|
MATCH (this)<-[:CHATS_IN]-(user:User)
|
||||||
|
WHERE NOT user.id = $cypherParams.currentUserId
|
||||||
|
OPTIONAL MATCH (:User)-[:AVATAR_IMAGE]->(image:Image)
|
||||||
|
RETURN image.url
|
||||||
|
""")
|
||||||
|
|
||||||
lastMessageAt: String
|
lastMessageAt: String
|
||||||
|
|
||||||
|
|||||||
@ -61,7 +61,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { roomQuery, createRoom } from '~/graphql/Rooms'
|
import { roomQuery, createRoom } from '~/graphql/Rooms'
|
||||||
import { messageQuery, createMessageMutation } from '~/graphql/Messages'
|
import { messageQuery, createMessageMutation, markMessagesAsSeen } from '~/graphql/Messages'
|
||||||
import chatStyle from '~/constants/chat.js'
|
import chatStyle from '~/constants/chat.js'
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
|
|
||||||
@ -84,7 +84,8 @@ export default {
|
|||||||
name: 'dummyItem',
|
name: 'dummyItem',
|
||||||
title: 'Just a dummy item',
|
title: 'Just a dummy item',
|
||||||
},
|
},
|
||||||
/* {
|
/*
|
||||||
|
{
|
||||||
name: 'inviteUser',
|
name: 'inviteUser',
|
||||||
title: 'Invite User',
|
title: 'Invite User',
|
||||||
},
|
},
|
||||||
@ -137,7 +138,7 @@ export default {
|
|||||||
rooms: [],
|
rooms: [],
|
||||||
roomsLoaded: false,
|
roomsLoaded: false,
|
||||||
roomPage: 0,
|
roomPage: 0,
|
||||||
roomPageSize: 10, // TODO pagination is a problem with single rooms - cant use
|
roomPageSize: 10,
|
||||||
singleRoom: !!this.singleRoomId || false,
|
singleRoom: !!this.singleRoomId || false,
|
||||||
selectedRoom: null,
|
selectedRoom: null,
|
||||||
loadingRooms: true,
|
loadingRooms: true,
|
||||||
@ -254,8 +255,19 @@ export default {
|
|||||||
fetchPolicy: 'no-cache',
|
fetchPolicy: 'no-cache',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const newMsgIds = Message.filter((m) => m.seen === false).map((m) => m.id)
|
||||||
|
if (newMsgIds.length) {
|
||||||
|
this.$apollo.mutate({
|
||||||
|
mutation: markMessagesAsSeen(),
|
||||||
|
variables: {
|
||||||
|
messageIds: newMsgIds,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const msgs = []
|
const msgs = []
|
||||||
;[...this.messages, ...Message].forEach((m) => {
|
;[...this.messages, ...Message].forEach((m) => {
|
||||||
|
if (m.senderId !== this.currentUser.id) m.seen = true
|
||||||
m.date = new Date(m.date).toDateString()
|
m.date = new Date(m.date).toDateString()
|
||||||
msgs[m.indexId] = m
|
msgs[m.indexId] = m
|
||||||
})
|
})
|
||||||
@ -272,6 +284,12 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async sendMessage(message) {
|
async sendMessage(message) {
|
||||||
|
// check for usersTag and change userid to username
|
||||||
|
message.usersTag.forEach((userTag) => {
|
||||||
|
const needle = `<usertag>${userTag.id}</usertag>`
|
||||||
|
const replacement = `<usertag>@${userTag.name.replaceAll(' ', '-').toLowerCase()}</usertag>`
|
||||||
|
message.content = message.content.replaceAll(needle, replacement)
|
||||||
|
})
|
||||||
try {
|
try {
|
||||||
await this.$apollo.mutate({
|
await this.$apollo.mutate({
|
||||||
mutation: createMessageMutation(),
|
mutation: createMessageMutation(),
|
||||||
|
|||||||
@ -33,3 +33,11 @@ export const createMessageMutation = () => {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const markMessagesAsSeen = () => {
|
||||||
|
return gql`
|
||||||
|
mutation ($messageIds: [String!]) {
|
||||||
|
MarkMessagesAsSeen(messageIds: $messageIds)
|
||||||
|
}
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user