Skip to content

Commit

Permalink
Merge pull request #4149 from nextcloud/backport/4139/stable18
Browse files Browse the repository at this point in the history
[stable18] Fix memory leak in message list
  • Loading branch information
nickvergessen authored Sep 15, 2020
2 parents 62c6c04 + 7589a77 commit c58dfa7
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/components/MessagesList/MessagesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import LoadingMessage from './LoadingMessage'
import { fetchMessages, lookForNewMessages } from '../../services/messagesService'
import CancelableRequest from '../../utils/cancelableRequest'
import Axios from '@nextcloud/axios'
import { subscribe } from '@nextcloud/event-bus'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import isInLobby from '../../mixins/isInLobby'
import debounce from 'debounce'
import { EventBus } from '../../services/EventBus'
Expand Down Expand Up @@ -213,18 +213,15 @@ export default {
this.scrollToBottom()
EventBus.$on('scrollChatToBottom', this.handleScrollChatToBottomEvent)
subscribe('networkOffline', () => {
console.debug('Canceling message request as we are offline')
this.cancelLookForNewMessages()
})
subscribe('networkOnline', () => {
console.debug('Restarting polling of new chat messages')
this.getNewMessages()
})
subscribe('networkOffline', this.handleNetworkOffline)
subscribe('networkOnline', this.handleNetworkOnline)
},
beforeDestroy() {
EventBus.$off('scrollChatToBottom', this.handleScrollChatToBottomEvent)
this.cancelLookForNewMessages()
unsubscribe('networkOffline', this.handleNetworkOffline)
unsubscribe('networkOnline', this.handleNetworkOnline)
},
methods: {
Expand Down Expand Up @@ -575,6 +572,16 @@ export default {
getFirstKnownMessageId() {
return this.messagesList[0].id.toString()
},
handleNetworkOffline() {
console.debug('Canceling message request as we are offline')
this.cancelLookForNewMessages()
},
handleNetworkOnline() {
console.debug('Restarting polling of new chat messages')
this.getNewMessages()
},
},
}
</script>
Expand Down

0 comments on commit c58dfa7

Please sign in to comment.