mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2026-04-06 01:25:38 +00:00
frontend rooms query, singleRoom gets an userid now, not a boolean
This commit is contained in:
parent
abdcdba355
commit
c2c96ee96c
@ -27,7 +27,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// import { roomQuery } from '~/graphql/Rooms'
|
import { roomQuery, createRoom } from '~/graphql/Rooms'
|
||||||
import { messageQuery } from '~/graphql/Messages'
|
import { messageQuery } from '~/graphql/Messages'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -36,16 +36,16 @@ export default {
|
|||||||
theme: {
|
theme: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
singleRoom: {
|
singleRoomId: {
|
||||||
type: Boolean,
|
type: String,
|
||||||
default: false,
|
default: null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
currentUserId: '1234',
|
currentUserId: '1234',
|
||||||
menuActions: [
|
menuActions: [
|
||||||
{
|
/* {
|
||||||
name: 'inviteUser',
|
name: 'inviteUser',
|
||||||
title: 'Invite User',
|
title: 'Invite User',
|
||||||
},
|
},
|
||||||
@ -56,7 +56,7 @@ export default {
|
|||||||
{
|
{
|
||||||
name: 'deleteRoom',
|
name: 'deleteRoom',
|
||||||
title: 'Delete Room',
|
title: 'Delete Room',
|
||||||
},
|
}, */
|
||||||
],
|
],
|
||||||
messageActions: [
|
messageActions: [
|
||||||
{
|
{
|
||||||
@ -93,16 +93,16 @@ export default {
|
|||||||
CANCEL_SELECT_MESSAGE: 'Annuler Sélection',
|
CANCEL_SELECT_MESSAGE: 'Annuler Sélection',
|
||||||
},
|
},
|
||||||
roomActions: [
|
roomActions: [
|
||||||
{
|
/* {
|
||||||
name: 'archiveRoom',
|
name: 'archiveRoom',
|
||||||
title: 'Archive Room',
|
title: 'Archive Room',
|
||||||
},
|
}, */
|
||||||
{ name: 'inviteUser', title: 'Invite User' },
|
// { name: 'inviteUser', title: 'Invite User' },
|
||||||
{ name: 'removeUser', title: 'Remove User' },
|
// { name: 'removeUser', title: 'Remove User' },
|
||||||
{ name: 'deleteRoom', title: 'Delete Room' },
|
// { name: 'deleteRoom', title: 'Delete Room' },
|
||||||
],
|
],
|
||||||
rooms: [
|
rooms: [
|
||||||
{
|
/* {
|
||||||
roomId: '1',
|
roomId: '1',
|
||||||
roomName: 'John Snow',
|
roomName: 'John Snow',
|
||||||
avatar: 'https://66.media.tumblr.com/avatar_c6a8eae4303e_512.pnj',
|
avatar: 'https://66.media.tumblr.com/avatar_c6a8eae4303e_512.pnj',
|
||||||
@ -120,15 +120,35 @@ export default {
|
|||||||
{ _id: '1234', username: 'Johnx Doe' },
|
{ _id: '1234', username: 'Johnx Doe' },
|
||||||
{ _id: '43210', username: 'Max J. Mustermann' },
|
{ _id: '43210', username: 'Max J. Mustermann' },
|
||||||
],
|
],
|
||||||
},
|
}, */
|
||||||
],
|
],
|
||||||
messages: [],
|
messages: [],
|
||||||
messagesLoaded: true,
|
messagesLoaded: true,
|
||||||
showDemoOptions: true,
|
showDemoOptions: true,
|
||||||
responsiveBreakpoint: 600,
|
responsiveBreakpoint: 600,
|
||||||
|
singleRoom: !!this.singleRoomId || false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
if(this.singleRoom){
|
||||||
|
this.$apollo
|
||||||
|
.mutate({
|
||||||
|
mutation: createRoom(),
|
||||||
|
variables: {
|
||||||
|
userId: this.singleRoomId
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
this.$apollo.queries.Rooms.refetch()
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
console.log(error)
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
// this.loading = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
fetchMessages({ room, options = {} }) {
|
fetchMessages({ room, options = {} }) {
|
||||||
// console.log(room, options)
|
// console.log(room, options)
|
||||||
@ -212,26 +232,35 @@ export default {
|
|||||||
}, 2000)
|
}, 2000)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// apollo: {
|
apollo: {
|
||||||
// Rooms: {
|
Rooms: {
|
||||||
// query() {
|
query() {
|
||||||
// return roomQuery()
|
return roomQuery()
|
||||||
// },
|
},
|
||||||
// update({ Room }) {
|
update({ Room }) {
|
||||||
// console.log('Rooms', Room)
|
console.log('Rooms', Room)
|
||||||
// if (!Room) {
|
if (!Room) {
|
||||||
// this.rooms = []
|
this.rooms = []
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
// this.rooms = Room
|
|
||||||
// },
|
// Backend result needs mapping of the following values
|
||||||
// error(error) {
|
// room[i].users[j].name -> room[i].users[j].username
|
||||||
// this.rooms = []
|
// room[i].users[j].avatar.url -> room[i].users[j].avatar
|
||||||
// this.$toast.error(error.message)
|
// also filter rooms for the single room
|
||||||
// },
|
this.rooms = Room.map((r) => {
|
||||||
// fetchPolicy: 'cache-and-network',
|
return {...r, users: r.users.map((u) => { return {...u, username: u.name, avatar: u.avatar?.url}})}
|
||||||
// },
|
}).filter((r) => this.singleRoom ? r.users.filter((u) => u.id === this.singleRoomId ).length > 0 : true)
|
||||||
// },
|
|
||||||
|
console.log(this.rooms)
|
||||||
|
},
|
||||||
|
error(error) {
|
||||||
|
this.rooms = []
|
||||||
|
this.$toast.error(error.message)
|
||||||
|
},
|
||||||
|
fetchPolicy: 'cache-and-network',
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|||||||
@ -4,9 +4,26 @@ export const roomQuery = () => gql`
|
|||||||
query {
|
query {
|
||||||
Room {
|
Room {
|
||||||
id
|
id
|
||||||
|
roomId
|
||||||
|
roomName
|
||||||
|
avatar
|
||||||
users {
|
users {
|
||||||
|
_id
|
||||||
id
|
id
|
||||||
|
name
|
||||||
|
avatar {
|
||||||
|
url
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
export const createRoom = () => gql`
|
||||||
|
mutation ($userId: ID!) {
|
||||||
|
CreateRoom(userId: $userId) {
|
||||||
|
id
|
||||||
|
roomId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -20,7 +20,7 @@
|
|||||||
x
|
x
|
||||||
</ds-button>
|
</ds-button>
|
||||||
</ds-text>
|
</ds-text>
|
||||||
<chat-module :singleRoom="true" />
|
<chat-module :singleRoomId="$store.getters['chat/showChat'].roomID"/>
|
||||||
</div>
|
</div>
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user