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
6 changes: 0 additions & 6 deletions src/components/CallView/shared/VideoVue.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ import storeConfig from '../../../store/storeConfig.js'
import EmitterMixin from '../../../utils/EmitterMixin.js'
import CallParticipantModel from '../../../utils/webrtc/models/CallParticipantModel.js'

global.ResizeObserver = jest.fn().mockImplementation(() => ({
observe: jest.fn(),
unobserve: jest.fn(),
disconnect: jest.fn(),
}))

describe('VideoVue.vue', () => {
let localVue
let store
Expand Down
17 changes: 17 additions & 0 deletions src/components/MessagesList/MessagesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ export default {
subscribe('networkOnline', this.handleNetworkOnline)
window.addEventListener('focus', this.onWindowFocus)

window.addEventListener('resize', this.updateSize)
this.resizeObserver = new ResizeObserver(this.updateSize)
this.resizeObserver.observe(this.$refs.scroller)

/**
* Every 30 seconds we remove expired messages from the store
*/
Expand All @@ -364,6 +368,11 @@ export default {
unsubscribe('networkOffline', this.handleNetworkOffline)
unsubscribe('networkOnline', this.handleNetworkOnline)

window.removeEventListener('resize', this.updateSize)
if (this.resizeObserver) {
this.resizeObserver.disconnect()
}

if (this.expirationInterval) {
clearInterval(this.expirationInterval)
this.expirationInterval = null
Expand All @@ -373,6 +382,14 @@ export default {
methods: {
t,
n,
updateSize() {
if (this.isChatScrolledToBottom) {
this.$refs.scroller.scrollTo({
top: this.$refs.scroller.scrollHeight,
})
}
},

prepareMessagesGroups(messages) {
let prevGroupMap = null
const groupsByDate = {}
Expand Down
6 changes: 6 additions & 0 deletions src/test-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ global.BroadcastChannel = jest.fn(() => ({
addEventListener: jest.fn(),
}))

global.ResizeObserver = jest.fn(() => ({
observe: jest.fn(),
unobserve: jest.fn(),
disconnect: jest.fn(),
}))

// Work around missing "URL.createObjectURL" (which is used in the code but not
// relevant for the tests) in jsdom: https://github.com/jsdom/jsdom/issues/1721
window.URL.createObjectURL = jest.fn()
Expand Down
Loading