From 10e241082b106915fe26696dd2cd809a9992cf26 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 16 Jun 2021 08:55:52 +0200 Subject: Slow down the participant list update when not visible There is not a lot use in updating the participant list every 2 seconds, when the list is not display, the sidebar closed or even the window hidden. Signed-off-by: Joas Schilling --- .../RightSidebar/Participants/ParticipantsTab.vue | 24 ++++++++++++++++++++-- src/components/RightSidebar/RightSidebar.vue | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'src/components/RightSidebar') diff --git a/src/components/RightSidebar/Participants/ParticipantsTab.vue b/src/components/RightSidebar/Participants/ParticipantsTab.vue index 18fb8626d..dea5e909b 100644 --- a/src/components/RightSidebar/Participants/ParticipantsTab.vue +++ b/src/components/RightSidebar/Participants/ParticipantsTab.vue @@ -86,6 +86,10 @@ export default { type: Boolean, required: true, }, + isActive: { + type: Boolean, + required: true, + }, }, data() { @@ -183,11 +187,27 @@ export default { } }, 250), - debounceUpdateParticipants: debounce(function() { + debounceUpdateParticipants() { + if (!this.$store.getters.windowIsVisible() + || !this.$store.getters.getSidebarStatus + || !this.isActive) { + this.debounceSlowUpdateParticipants() + } + + this.debounceFastUpdateParticipants() + }, + + debounceSlowUpdateParticipants: debounce(function() { + if (!this.fetchingParticipants) { + this.cancelableGetParticipants() + } + }, 15000), + + debounceFastUpdateParticipants: debounce(function() { if (!this.fetchingParticipants) { this.cancelableGetParticipants() } - }, 2000), + }, 3000), async fetchSearchResults() { try { diff --git a/src/components/RightSidebar/RightSidebar.vue b/src/components/RightSidebar/RightSidebar.vue index 2313beac1..acf8579b6 100644 --- a/src/components/RightSidebar/RightSidebar.vue +++ b/src/components/RightSidebar/RightSidebar.vue @@ -52,6 +52,7 @@ :name="t('spreed', 'Participants')" icon="icon-contacts-dark"> -- cgit v1.2.3