mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Merge branch 'master' into refactor-webapp-workflow
This commit is contained in:
commit
8d962c738a
@ -92,6 +92,21 @@ describe('Room', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('user id is self', () => {
|
||||||
|
it('throws error', async () => {
|
||||||
|
await expect(
|
||||||
|
mutate({
|
||||||
|
mutation: createRoomMutation(),
|
||||||
|
variables: {
|
||||||
|
userId: 'chatting-user',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
).resolves.toMatchObject({
|
||||||
|
errors: [{ message: 'Cannot create a room with self' }],
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('user id exists', () => {
|
describe('user id exists', () => {
|
||||||
it('returns the id of the room', async () => {
|
it('returns the id of the room', async () => {
|
||||||
const result = await mutate({
|
const result = await mutate({
|
||||||
|
|||||||
@ -32,6 +32,9 @@ export default {
|
|||||||
const {
|
const {
|
||||||
user: { id: currentUserId },
|
user: { id: currentUserId },
|
||||||
} = context
|
} = context
|
||||||
|
if (userId === currentUserId) {
|
||||||
|
throw new Error('Cannot create a room with self')
|
||||||
|
}
|
||||||
const session = context.driver.session()
|
const session = context.driver.session()
|
||||||
const writeTxResultPromise = session.writeTransaction(async (transaction) => {
|
const writeTxResultPromise = session.writeTransaction(async (transaction) => {
|
||||||
const createRoomCypher = `
|
const createRoomCypher = `
|
||||||
|
|||||||
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
When you overtake this deploy and rebrand repo to your network you have to recognize the following changes and doings:
|
When you overtake this deploy and rebrand repo to your network you have to recognize the following changes and doings:
|
||||||
|
|
||||||
|
## Version >= 2.7.0 with 'ocelotDockerVersionTag' 2.7.0-470
|
||||||
|
|
||||||
|
- You have to rename all `.js` files to `.ts` in `branding/constants`
|
||||||
|
|
||||||
## Version >= 2.4.0 with 'ocelotDockerVersionTag' 2.4.0-298
|
## Version >= 2.4.0 with 'ocelotDockerVersionTag' 2.4.0-298
|
||||||
|
|
||||||
- You have to set `SHOW_CONTENT_FILTER_HEADER_MENU` and `SHOW_CONTENT_FILTER_MASONRY_GRID` in `branding/constants/filter.js` originally in main code file `webapp/constants/filter.js` to your preferred value.
|
- You have to set `SHOW_CONTENT_FILTER_HEADER_MENU` and `SHOW_CONTENT_FILTER_MASONRY_GRID` in `branding/constants/filter.js` originally in main code file `webapp/constants/filter.js` to your preferred value.
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
<client-only>
|
<client-only>
|
||||||
<vue-advanced-chat
|
<vue-advanced-chat
|
||||||
:theme="theme"
|
:theme="theme"
|
||||||
:current-user-id="currentUserId"
|
:current-user-id="currentUser.id"
|
||||||
:room-id="null"
|
:room-id="null"
|
||||||
:template-actions="JSON.stringify(templatesText)"
|
:template-actions="JSON.stringify(templatesText)"
|
||||||
:menu-actions="JSON.stringify(menuActions)"
|
:menu-actions="JSON.stringify(menuActions)"
|
||||||
@ -28,7 +28,8 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { roomQuery, createRoom } from '~/graphql/Rooms'
|
import { roomQuery, createRoom } from '~/graphql/Rooms'
|
||||||
import { messageQuery } from '~/graphql/Messages'
|
import { messageQuery, createMessageMutation } from '~/graphql/Messages'
|
||||||
|
import { mapGetters } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Chat',
|
name: 'Chat',
|
||||||
@ -43,7 +44,6 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
currentUserId: '1234',
|
|
||||||
menuActions: [
|
menuActions: [
|
||||||
/* {
|
/* {
|
||||||
name: 'inviteUser',
|
name: 'inviteUser',
|
||||||
@ -131,15 +131,15 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters({
|
||||||
|
currentUser: 'auth/user',
|
||||||
|
}),
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchMessages({ room, options = {} }) {
|
fetchMessages({ room, options = {} }) {
|
||||||
// console.log(room, options)
|
|
||||||
this.messagesLoaded = false
|
this.messagesLoaded = false
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
if (options.reset) {
|
|
||||||
// console.log('reset messages')
|
|
||||||
this.messages = [] // this.addMessages(true)
|
|
||||||
} else {
|
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
data: { Message },
|
data: { Message },
|
||||||
@ -148,70 +148,34 @@ export default {
|
|||||||
variables: {
|
variables: {
|
||||||
roomId: room.id,
|
roomId: room.id,
|
||||||
},
|
},
|
||||||
|
fetchPolicy: 'no-cache',
|
||||||
})
|
})
|
||||||
// console.log('Messages', Message)
|
|
||||||
this.messages = Message
|
this.messages = Message
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// console.log('Error', error)
|
this.messages = []
|
||||||
this.messages = [] // this.addMessages(true)
|
|
||||||
this.$toast.error(error.message)
|
this.$toast.error(error.message)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
this.messagesLoaded = true
|
this.messagesLoaded = true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
/* addMessages(reset) {
|
refetchMessage(roomId) {
|
||||||
const messages = []
|
this.fetchMessages({ room: this.rooms.find((r) => r.roomId === roomId) })
|
||||||
|
},
|
||||||
|
|
||||||
for (let i = 0; i < 30; i++) {
|
async sendMessage(message) {
|
||||||
messages.push({
|
try {
|
||||||
_id: reset ? i : this.messages.length + i,
|
await this.$apollo.mutate({
|
||||||
content: `${reset ? '' : 'paginated'} message ${i + 1}`,
|
mutation: createMessageMutation(),
|
||||||
senderId: '4321',
|
variables: {
|
||||||
username: 'John Doe',
|
roomId: message.roomId,
|
||||||
date: '13 November',
|
|
||||||
timestamp: '10:20',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
messages.push({
|
|
||||||
_id: '31',
|
|
||||||
content: `Hallo Welt`,
|
|
||||||
senderId: '1234',
|
|
||||||
username: 'John Doe',
|
|
||||||
date: '13 November',
|
|
||||||
timestamp: '10:20',
|
|
||||||
})
|
|
||||||
|
|
||||||
return messages
|
|
||||||
}, */
|
|
||||||
|
|
||||||
sendMessage(message) {
|
|
||||||
this.messages = [
|
|
||||||
...this.messages,
|
|
||||||
{
|
|
||||||
_id: this.messages.length,
|
|
||||||
content: message.content,
|
content: message.content,
|
||||||
senderId: this.currentUserId,
|
|
||||||
timestamp: new Date().toString().substring(16, 21),
|
|
||||||
date: new Date().toDateString(),
|
|
||||||
},
|
},
|
||||||
]
|
})
|
||||||
},
|
} catch (error) {
|
||||||
|
this.$toast.error(error.message)
|
||||||
addNewMessage() {
|
}
|
||||||
setTimeout(() => {
|
this.refetchMessage(message.roomId)
|
||||||
this.messages = [
|
|
||||||
...this.messages,
|
|
||||||
{
|
|
||||||
_id: this.messages.length,
|
|
||||||
content: 'NEW MESSAGE',
|
|
||||||
senderId: '1234',
|
|
||||||
timestamp: new Date().toString().substring(16, 21),
|
|
||||||
date: new Date().toDateString(),
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}, 2000)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
apollo: {
|
apollo: {
|
||||||
@ -220,7 +184,6 @@ export default {
|
|||||||
return roomQuery()
|
return roomQuery()
|
||||||
},
|
},
|
||||||
update({ Room }) {
|
update({ Room }) {
|
||||||
// console.log('Rooms', Room)
|
|
||||||
if (!Room) {
|
if (!Room) {
|
||||||
this.rooms = []
|
this.rooms = []
|
||||||
return
|
return
|
||||||
@ -240,14 +203,12 @@ export default {
|
|||||||
}).filter((r) =>
|
}).filter((r) =>
|
||||||
this.singleRoom ? r.users.filter((u) => u.id === this.singleRoomId).length > 0 : true,
|
this.singleRoom ? r.users.filter((u) => u.id === this.singleRoomId).length > 0 : true,
|
||||||
)
|
)
|
||||||
|
|
||||||
// console.log(this.rooms)
|
|
||||||
},
|
},
|
||||||
error(error) {
|
error(error) {
|
||||||
this.rooms = []
|
this.rooms = []
|
||||||
this.$toast.error(error.message)
|
this.$toast.error(error.message)
|
||||||
},
|
},
|
||||||
fetchPolicy: 'cache-and-network',
|
fetchPolicy: 'no-cache',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,9 @@ export const messageQuery = () => {
|
|||||||
return gql`
|
return gql`
|
||||||
query ($roomId: ID!) {
|
query ($roomId: ID!) {
|
||||||
Message(roomId: $roomId) {
|
Message(roomId: $roomId) {
|
||||||
|
_id
|
||||||
id
|
id
|
||||||
|
senderId
|
||||||
content
|
content
|
||||||
author {
|
author {
|
||||||
id
|
id
|
||||||
@ -13,3 +15,14 @@ export const messageQuery = () => {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const createMessageMutation = () => {
|
||||||
|
return gql`
|
||||||
|
mutation ($roomId: ID!, $content: String!) {
|
||||||
|
CreateMessage(roomId: $roomId, content: $content) {
|
||||||
|
id
|
||||||
|
content
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@ describe('default.vue', () => {
|
|||||||
getters: {
|
getters: {
|
||||||
'auth/isLoggedIn': () => true,
|
'auth/isLoggedIn': () => true,
|
||||||
'chat/showChat': () => {
|
'chat/showChat': () => {
|
||||||
return { showChat: false, roomID: 'u0' }
|
return { showChat: false, roomID: null }
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
<div v-if="$store.getters['chat/showChat'].showChat" class="chat-modul">
|
<div v-if="$store.getters['chat/showChat'].showChat" class="chat-modul">
|
||||||
<ds-text align="right" class="close">
|
<ds-text align="right" class="close">
|
||||||
RoomID: {{ $store.getters['chat/showChat'].roomID }}
|
RoomID: {{ $store.getters['chat/showChat'].roomID }}
|
||||||
<ds-button @click="$store.commit('chat/SET_OPEN_CHAT', { showChat: false, roomID: 'u0' })">
|
<ds-button @click="$store.commit('chat/SET_OPEN_CHAT', { showChat: false, roomID: null })">
|
||||||
x
|
x
|
||||||
</ds-button>
|
</ds-button>
|
||||||
</ds-text>
|
</ds-text>
|
||||||
@ -41,6 +41,9 @@ export default {
|
|||||||
ChatModule,
|
ChatModule,
|
||||||
},
|
},
|
||||||
mixins: [seo, mobile()],
|
mixins: [seo, mobile()],
|
||||||
|
beforeCreate() {
|
||||||
|
this.$store.commit('chat/SET_OPEN_CHAT', { showChat: false, roomID: null })
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
export const state = () => {
|
export const state = () => {
|
||||||
return {
|
return {
|
||||||
showChat: false,
|
showChat: false,
|
||||||
roomID: 'u0',
|
roomID: null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const mutations = {
|
export const mutations = {
|
||||||
SET_OPEN_CHAT(state, ctx) {
|
SET_OPEN_CHAT(state, ctx) {
|
||||||
state.showChat = ctx.showChat || false
|
state.showChat = ctx.showChat || false
|
||||||
state.roomID = ctx.roomID || 'u0'
|
state.roomID = ctx.roomID || null
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user