Skip to content

Commit

Permalink
Merge pull request #4139 from nextcloud/fix-memory-leak-in-message-list
Browse files Browse the repository at this point in the history
Fix memory leak in message list
  • Loading branch information
nickvergessen authored Sep 14, 2020
2 parents 0f09c5c + bbd0277 commit c0d333b
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 @@ -69,7 +69,7 @@ import MessagesGroup from './MessagesGroup/MessagesGroup'
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 @@ -233,18 +233,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 @@ -595,6 +592,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 c0d333b

Please sign in to comment.