summaryrefslogtreecommitdiffstats
path: root/src/components/LeftSidebar/ConversationsList/ConversationsList.vue
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-05-12 16:20:46 +0200
committerJoas Schilling <coding@schilljs.com>2020-05-12 19:12:39 +0200
commit2178a65db64fd09b037b4bb9999b3e0f3ea06ca6 (patch)
tree8e8dec83d2435e750280ab877492407fba37eb98 /src/components/LeftSidebar/ConversationsList/ConversationsList.vue
parente5ccfbf6ae21710ddcd14c66e63c030d22f35efa (diff)
Only allow one fetch room request in parallel
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'src/components/LeftSidebar/ConversationsList/ConversationsList.vue')
-rw-r--r--src/components/LeftSidebar/ConversationsList/ConversationsList.vue14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/components/LeftSidebar/ConversationsList/ConversationsList.vue b/src/components/LeftSidebar/ConversationsList/ConversationsList.vue
index d1716e7af..de95ad487 100644
--- a/src/components/LeftSidebar/ConversationsList/ConversationsList.vue
+++ b/src/components/LeftSidebar/ConversationsList/ConversationsList.vue
@@ -44,6 +44,7 @@ import LoadingHint from '../../LoadingHint'
import { fetchConversations } from '../../../services/conversationsService'
import { joinConversation, leaveConversation } from '../../../services/participantsService'
import { EventBus } from '../../../services/EventBus'
+import debounce from 'debounce'
export default {
name: 'ConversationsList',
@@ -62,6 +63,7 @@ export default {
data() {
return {
initialisedConversations: false,
+ isFetchingConversations: false,
}
},
@@ -83,7 +85,9 @@ export default {
mounted() {
/** Refreshes the conversations every 30 seconds */
window.setInterval(() => {
- this.fetchConversations()
+ if (!this.isFetchingConversations) {
+ this.fetchConversations()
+ }
}, 30000)
EventBus.$on('routeChange', this.onRouteChange)
@@ -110,8 +114,12 @@ export default {
return conversation2.lastActivity - conversation1.lastActivity
},
+
async fetchConversations() {
- /** Fetches the conversations from the server and then adds them one by one
+ this.isFetchingConversations = true
+
+ /**
+ * Fetches the conversations from the server and then adds them one by one
* to the store.
*/
try {
@@ -131,8 +139,10 @@ export default {
EventBus.$emit('conversationsReceived', {
singleConversation: false,
})
+ this.isFetchingConversations = false
} catch (error) {
console.debug('Error while fetching conversations: ', error)
+ this.isFetchingConversations = false
}
},
// Emit the click event so the search text in the leftsidebar can be reset.