Skip to content

Commit b5fedb1

Browse files
authored
Merge pull request #14266 from nextcloud/fix/noid/message-list-sticky
2 parents 765a058 + 6be69f2 commit b5fedb1

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

src/components/CallView/shared/VideoVue.spec.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ import storeConfig from '../../../store/storeConfig.js'
1414
import EmitterMixin from '../../../utils/EmitterMixin.js'
1515
import CallParticipantModel from '../../../utils/webrtc/models/CallParticipantModel.js'
1616

17-
global.ResizeObserver = jest.fn().mockImplementation(() => ({
18-
observe: jest.fn(),
19-
unobserve: jest.fn(),
20-
disconnect: jest.fn(),
21-
}))
22-
2317
describe('VideoVue.vue', () => {
2418
let localVue
2519
let store

src/components/MessagesList/MessagesList.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,10 @@ export default {
341341
subscribe('networkOnline', this.handleNetworkOnline)
342342
window.addEventListener('focus', this.onWindowFocus)
343343

344+
window.addEventListener('resize', this.updateSize)
345+
this.resizeObserver = new ResizeObserver(this.updateSize)
346+
this.resizeObserver.observe(this.$refs.scroller)
347+
344348
/**
345349
* Every 30 seconds we remove expired messages from the store
346350
*/
@@ -364,6 +368,11 @@ export default {
364368
unsubscribe('networkOffline', this.handleNetworkOffline)
365369
unsubscribe('networkOnline', this.handleNetworkOnline)
366370

371+
window.removeEventListener('resize', this.updateSize)
372+
if (this.resizeObserver) {
373+
this.resizeObserver.disconnect()
374+
}
375+
367376
if (this.expirationInterval) {
368377
clearInterval(this.expirationInterval)
369378
this.expirationInterval = null
@@ -373,6 +382,14 @@ export default {
373382
methods: {
374383
t,
375384
n,
385+
updateSize() {
386+
if (this.isChatScrolledToBottom) {
387+
this.$refs.scroller.scrollTo({
388+
top: this.$refs.scroller.scrollHeight,
389+
})
390+
}
391+
},
392+
376393
prepareMessagesGroups(messages) {
377394
let prevGroupMap = null
378395
const groupsByDate = {}

src/test-setup.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ global.BroadcastChannel = jest.fn(() => ({
109109
addEventListener: jest.fn(),
110110
}))
111111

112+
global.ResizeObserver = jest.fn(() => ({
113+
observe: jest.fn(),
114+
unobserve: jest.fn(),
115+
disconnect: jest.fn(),
116+
}))
117+
112118
// Work around missing "URL.createObjectURL" (which is used in the code but not
113119
// relevant for the tests) in jsdom: https://github.com/jsdom/jsdom/issues/1721
114120
window.URL.createObjectURL = jest.fn()

0 commit comments

Comments
 (0)