Skip to content

Commit

Permalink
Merge pull request #14268 from nextcloud/backport/14266/stable31
Browse files Browse the repository at this point in the history
  • Loading branch information
Antreesy authored Jan 31, 2025
2 parents 1e110f0 + 355ac52 commit 4abf5ca
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
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

0 comments on commit 4abf5ca

Please sign in to comment.