Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/components/EmojiPickerContainer/EmojiPickerContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

<script>
import SvgIcon from '../SvgIcon/SvgIcon'
import { findParentBySelector } from '../../utils/element-selector'

export default {
name: 'EmojiPickerContainer',
Expand Down Expand Up @@ -121,9 +122,7 @@ export default {
},
setEmojiPickerPosition(clientY, innerWidth, innerHeight) {
const mobileSize = innerWidth < 500 || innerHeight < 700
const roomFooterRef = document
.querySelector('vue-advanced-chat')
.shadowRoot.getElementById('room-footer')
const roomFooterRef = findParentBySelector(this.$el, '#room-footer')

if (!roomFooterRef) {
if (mobileSize) this.emojiPickerRight = '-50px'
Expand Down
8 changes: 2 additions & 6 deletions src/lib/Room/Room.vue
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,11 @@ export default {
this.observer.disconnect()
}

const loader = document
.querySelector('vue-advanced-chat')
.shadowRoot.getElementById('infinite-loader-messages')
const loader = this.$el.querySelector('#infinite-loader-messages')

if (loader) {
const options = {
root: document
.querySelector('vue-advanced-chat')
.shadowRoot.getElementById('messages-list'),
root: this.$el.querySelector('#messages-list'),
rootMargin: `${this.scrollDistance}px`,
threshold: 0
}
Expand Down
14 changes: 1 addition & 13 deletions src/lib/Room/RoomFooter/RoomEmojis/RoomEmojis.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<template>
<transition name="vac-slide-up">
<div
v-if="filteredEmojis.length"
class="vac-emojis-container"
:style="{ bottom: `${footerHeight}px` }"
>
<div v-if="filteredEmojis.length" class="vac-emojis-container">
<div
v-for="(emoji, index) in filteredEmojis"
:key="emoji"
Expand Down Expand Up @@ -37,14 +33,6 @@ export default {
}
},

computed: {
footerHeight() {
return document
.querySelector('vue-advanced-chat')
.shadowRoot.getElementById('room-footer').clientHeight
}
},

watch: {
filteredEmojis(val, oldVal) {
if (!oldVal.length || val.length !== oldVal.length) {
Expand Down
6 changes: 0 additions & 6 deletions src/lib/Room/RoomFooter/RoomFiles/RoomFiles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<div
v-if="files.length"
class="vac-room-files-container"
:style="{ bottom: `${footerHeight}px` }"
>
<div class="vac-files-box">
<div v-for="(file, i) in files" :key="i">
Expand Down Expand Up @@ -49,11 +48,6 @@ export default {
emits: ['remove-file', 'reset-message'],

computed: {
footerHeight() {
return document
.querySelector('vue-advanced-chat')
.shadowRoot.getElementById('room-footer').clientHeight
}
}
}
</script>
6 changes: 0 additions & 6 deletions src/lib/Room/RoomFooter/RoomMessageReply/RoomMessageReply.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<div
v-if="messageReply"
class="vac-reply-container"
:style="{ bottom: `${footerHeight}px` }"
>
<div class="vac-reply-box">
<div class="vac-reply-info">
Expand Down Expand Up @@ -98,11 +97,6 @@ export default {
emits: ['reset-message'],

computed: {
footerHeight() {
return document
.querySelector('vue-advanced-chat')
.shadowRoot.getElementById('room-footer').clientHeight
},
firstFile() {
return this.messageReply?.files?.length ? this.messageReply.files[0] : {}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<div
v-if="filteredTemplatesText.length"
class="vac-template-container vac-app-box-shadow"
:style="{ bottom: `${footerHeight}px` }"
>
<div
v-for="(template, index) in filteredTemplatesText"
Expand Down Expand Up @@ -44,14 +43,6 @@ export default {
}
},

computed: {
footerHeight() {
return document
.querySelector('vue-advanced-chat')
.shadowRoot.getElementById('room-footer').clientHeight
}
},

watch: {
filteredTemplatesText(val, oldVal) {
if (!oldVal.length || val.length !== oldVal.length) {
Expand Down
14 changes: 1 addition & 13 deletions src/lib/Room/RoomFooter/RoomUsersTag/RoomUsersTag.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<template>
<transition name="vac-slide-up">
<div
v-if="filteredUsersTag.length"
class="vac-tags-container"
:style="{ bottom: `${footerHeight}px` }"
>
<div v-if="filteredUsersTag.length" class="vac-tags-container">
<div
v-for="(user, index) in filteredUsersTag"
:key="user._id"
Expand Down Expand Up @@ -46,14 +42,6 @@ export default {
}
},

computed: {
footerHeight() {
return document
.querySelector('vue-advanced-chat')
.shadowRoot.getElementById('room-footer').clientHeight
}
},

watch: {
filteredUsersTag(val, oldVal) {
if (!oldVal.length || val.length !== oldVal.length) {
Expand Down
4 changes: 1 addition & 3 deletions src/lib/Room/RoomMessage/AudioPlayer/AudioPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ export default {
},

mounted() {
this.player = document
.querySelector('vue-advanced-chat')
.shadowRoot.getElementById(this.playerUniqId)
this.player = this.$el.querySelector('#' + this.playerUniqId)

this.player.addEventListener('ended', () => {
this.isPlaying = false
Expand Down
5 changes: 2 additions & 3 deletions src/lib/Room/RoomMessage/MessageActions/MessageActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ import vClickOutside from '../../../../utils/on-click-outside'

import SvgIcon from '../../../../components/SvgIcon/SvgIcon'
import EmojiPickerContainer from '../../../../components/EmojiPickerContainer/EmojiPickerContainer'
import { findParentBySelector } from '../../../../utils/element-selector'

export default {
name: 'MessageActions',
Expand Down Expand Up @@ -170,9 +171,7 @@ export default {
if (!this.optionsOpened) return

setTimeout(() => {
const roomFooterRef = document
.querySelector('vue-advanced-chat')
.shadowRoot.getElementById('room-footer')
const roomFooterRef = findParentBySelector(this.$el, '#room-footer')

if (
!roomFooterRef ||
Expand Down
8 changes: 2 additions & 6 deletions src/lib/RoomsList/RoomsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,11 @@ export default {
this.observer.disconnect()
}

const loader = document
.querySelector('vue-advanced-chat')
.shadowRoot.getElementById('infinite-loader-rooms')
const loader = this.$el.querySelector('#infinite-loader-rooms')

if (loader) {
const options = {
root: document
.querySelector('vue-advanced-chat')
.shadowRoot.getElementById('rooms-list'),
root: this.$el.querySelector('#rooms-list'),
rootMargin: `${this.scrollDistance}px`,
threshold: 0
}
Expand Down
8 changes: 8 additions & 0 deletions src/utils/element-selector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export function findParentBySelector(node, selector) {
while (node && !node.querySelector(selector)) {
node = node.parentNode
const element = node.querySelector(selector)
if (element) return element
}
return null
}