mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
Merge branch 'master' into chat-notifications
This commit is contained in:
commit
829ea5ee0c
@ -25,7 +25,7 @@ type Room {
|
||||
OPTIONAL MATCH (user)-[:AVATAR_IMAGE]->(image:Image)
|
||||
RETURN image.url
|
||||
""")
|
||||
|
||||
|
||||
lastMessageAt: String
|
||||
|
||||
lastMessage: Message @cypher(statement: """
|
||||
|
||||
@ -61,7 +61,7 @@
|
||||
|
||||
<script>
|
||||
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 { mapGetters } from 'vuex'
|
||||
|
||||
@ -84,19 +84,20 @@ export default {
|
||||
name: 'dummyItem',
|
||||
title: 'Just a dummy item',
|
||||
},
|
||||
/* {
|
||||
name: 'inviteUser',
|
||||
title: 'Invite User',
|
||||
},
|
||||
{
|
||||
name: 'removeUser',
|
||||
title: 'Remove User',
|
||||
},
|
||||
{
|
||||
name: 'deleteRoom',
|
||||
title: 'Delete Room',
|
||||
},
|
||||
*/
|
||||
/*
|
||||
{
|
||||
name: 'inviteUser',
|
||||
title: 'Invite User',
|
||||
},
|
||||
{
|
||||
name: 'removeUser',
|
||||
title: 'Remove User',
|
||||
},
|
||||
{
|
||||
name: 'deleteRoom',
|
||||
title: 'Delete Room',
|
||||
},
|
||||
*/
|
||||
],
|
||||
messageActions: [
|
||||
/*
|
||||
@ -137,7 +138,7 @@ export default {
|
||||
rooms: [],
|
||||
roomsLoaded: false,
|
||||
roomPage: 0,
|
||||
roomPageSize: 10, // TODO pagination is a problem with single rooms - cant use
|
||||
roomPageSize: 10,
|
||||
singleRoom: !!this.singleRoomId || false,
|
||||
selectedRoom: null,
|
||||
loadingRooms: true,
|
||||
@ -254,8 +255,19 @@ export default {
|
||||
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 = []
|
||||
;[...this.messages, ...Message].forEach((m) => {
|
||||
if (m.senderId !== this.currentUser.id) m.seen = true
|
||||
m.date = new Date(m.date).toDateString()
|
||||
msgs[m.indexId] = m
|
||||
})
|
||||
@ -272,6 +284,12 @@ export default {
|
||||
},
|
||||
|
||||
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 {
|
||||
await this.$apollo.mutate({
|
||||
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