mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Create the chat room on user search in chats function
This commit is contained in:
parent
26282c67b7
commit
3d9a9cd5a0
@ -5,28 +5,11 @@
|
|||||||
<ds-space margin-bottom="small" />
|
<ds-space margin-bottom="small" />
|
||||||
<ds-space>
|
<ds-space>
|
||||||
<select-user-search :id="id" ref="selectUserSearch" @select-user="selectUser" />
|
<select-user-search :id="id" ref="selectUserSearch" @select-user="selectUser" />
|
||||||
<!-- <ds-modal
|
|
||||||
v-if="isOpen"
|
|
||||||
force
|
|
||||||
extended
|
|
||||||
:confirm-label="$t('group.modal.confirm')"
|
|
||||||
:cancel-label="$t('group.modal.cancel')"
|
|
||||||
:title="$t('group.modal.confirmAddGroupMemberTitle')"
|
|
||||||
v-model="isOpen"
|
|
||||||
@close="closeModal"
|
|
||||||
@confirm="confirmModal"
|
|
||||||
@cancel="cancelModal"
|
|
||||||
>
|
|
||||||
<ds-text size="large">
|
|
||||||
{{ $t('group.modal.confirmAddGroupMemberText', { name: user.name }) }}
|
|
||||||
</ds-text>
|
|
||||||
</ds-modal> -->
|
|
||||||
</ds-space>
|
</ds-space>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// import { changeGroupMemberRoleMutation } from '~/graphql/groups.js'
|
|
||||||
import SelectUserSearch from '~/components/generic/SelectUserSearch/SelectUserSearch'
|
import SelectUserSearch from '~/components/generic/SelectUserSearch/SelectUserSearch'
|
||||||
import UserTeaser from '~/components/UserTeaser/UserTeaser.vue'
|
import UserTeaser from '~/components/UserTeaser/UserTeaser.vue'
|
||||||
|
|
||||||
@ -37,10 +20,6 @@ export default {
|
|||||||
SelectUserSearch,
|
SelectUserSearch,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
// groupId: {
|
|
||||||
// type: String,
|
|
||||||
// required: true,
|
|
||||||
// },
|
|
||||||
// chatRooms: {
|
// chatRooms: {
|
||||||
// type: Array,
|
// type: Array,
|
||||||
// default: [],
|
// default: [],
|
||||||
@ -50,23 +29,9 @@ export default {
|
|||||||
return {
|
return {
|
||||||
id: 'search-user-to-add-to-group',
|
id: 'search-user-to-add-to-group',
|
||||||
user: {},
|
user: {},
|
||||||
// isOpen: false,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// cancelModal() {
|
|
||||||
// this.$refs.selectUserSearch.clear()
|
|
||||||
// // this.isOpen = false
|
|
||||||
// },
|
|
||||||
// closeModal() {
|
|
||||||
// this.$refs.selectUserSearch.clear()
|
|
||||||
// // this.isOpen = false
|
|
||||||
// },
|
|
||||||
// confirmModal() {
|
|
||||||
// this.addChatRoom()
|
|
||||||
// // this.isOpen = false
|
|
||||||
// this.$refs.selectUserSearch.clear()
|
|
||||||
// },
|
|
||||||
selectUser(user) {
|
selectUser(user) {
|
||||||
this.user = user
|
this.user = user
|
||||||
// if (this.groupMembers.find((member) => member.id === this.user.id)) {
|
// if (this.groupMembers.find((member) => member.id === this.user.id)) {
|
||||||
@ -76,27 +41,10 @@ export default {
|
|||||||
// }
|
// }
|
||||||
this.$refs.selectUserSearch.clear()
|
this.$refs.selectUserSearch.clear()
|
||||||
this.$emit('close-user-search')
|
this.$emit('close-user-search')
|
||||||
this.addChatRoom()
|
this.addChatRoom(this.user?.id)
|
||||||
},
|
},
|
||||||
async addChatRoom() {
|
async addChatRoom(userId) {
|
||||||
this.$emit('load-chat-rooms', 'XXX') // Wolle
|
this.$emit('add-chat-room', userId)
|
||||||
// const newRole = 'usual'
|
|
||||||
// const username = this.user.name
|
|
||||||
// try {
|
|
||||||
// await this.$apollo.mutate({
|
|
||||||
// mutation: changeGroupMemberRoleMutation(),
|
|
||||||
// variables: { groupId: this.groupId, userId: this.user.id, roleInGroup: newRole },
|
|
||||||
// })
|
|
||||||
// this.$toast.success(
|
|
||||||
// this.$t('group.addMemberToGroupSuccess', {
|
|
||||||
// role: this.$t(`group.roles.${newRole}`),
|
|
||||||
// name: username,
|
|
||||||
// }),
|
|
||||||
// )
|
|
||||||
// this.$emit('loadGroupMembers')
|
|
||||||
// } catch (error) {
|
|
||||||
// this.$toast.error(error.message)
|
|
||||||
// }
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -160,22 +160,7 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if (this.singleRoom) {
|
if (this.singleRoom) {
|
||||||
this.$apollo
|
this.newRoom(this.roomId)
|
||||||
.mutate({
|
|
||||||
mutation: createRoom(),
|
|
||||||
variables: {
|
|
||||||
userId: this.roomId,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then(({ data: { CreateRoom } }) => {
|
|
||||||
this.fetchRooms({ room: CreateRoom })
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
this.$toast.error(error)
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
// this.loading = false
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
this.fetchRooms()
|
this.fetchRooms()
|
||||||
}
|
}
|
||||||
@ -366,6 +351,25 @@ export default {
|
|||||||
addRoom() {
|
addRoom() {
|
||||||
this.$emit('open-close-user-search')
|
this.$emit('open-close-user-search')
|
||||||
},
|
},
|
||||||
|
|
||||||
|
newRoom(userId) {
|
||||||
|
this.$apollo
|
||||||
|
.mutate({
|
||||||
|
mutation: createRoom(),
|
||||||
|
variables: {
|
||||||
|
userId,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(({ data: { CreateRoom } }) => {
|
||||||
|
this.fetchRooms({ room: CreateRoom })
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
this.$toast.error(error)
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
// this.loading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -3,13 +3,14 @@
|
|||||||
<ds-heading tag="h1">{{ $t('chat.page.headline') }}</ds-heading>
|
<ds-heading tag="h1">{{ $t('chat.page.headline') }}</ds-heading>
|
||||||
<add-chat-room-by-user-search
|
<add-chat-room-by-user-search
|
||||||
v-if="showUserSearch"
|
v-if="showUserSearch"
|
||||||
@load-chat-rooms="loadChatRooms"
|
@add-chat-room="addChatRoom"
|
||||||
@close-user-search="showUserSearch = false"
|
@close-user-search="showUserSearch = false"
|
||||||
/>
|
/>
|
||||||
<!-- Wolle :chatRooms="chatRooms" -->
|
<!-- Wolle :chatRooms="chatRooms" -->
|
||||||
<ds-space margin-bottom="small" />
|
<ds-space margin-bottom="small" />
|
||||||
<chat
|
<chat
|
||||||
:roomId="getShowChat.showChat ? getShowChat.roomID : null"
|
:roomId="getShowChat.showChat ? getShowChat.roomID : null"
|
||||||
|
ref="chat"
|
||||||
@open-close-user-search="showUserSearch = !showUserSearch"
|
@open-close-user-search="showUserSearch = !showUserSearch"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -43,8 +44,9 @@ export default {
|
|||||||
...mapMutations({
|
...mapMutations({
|
||||||
showChat: 'chat/SET_OPEN_CHAT',
|
showChat: 'chat/SET_OPEN_CHAT',
|
||||||
}),
|
}),
|
||||||
loadChatRooms(newChatRoomID) {
|
addChatRoom(userID) {
|
||||||
console.log('loadChatRooms !!! newChatRoomID: ', newChatRoomID)
|
console.log('addChatRoom !!! newChatRoomID: ', userID)
|
||||||
|
this.$refs.chat.newRoom(userID)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user