-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make listeners exclusive to TopBar only
Signed-off-by: DorraJaouad <[email protected]>
- Loading branch information
1 parent
d55ce12
commit 5154841
Showing
2 changed files
with
12 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ | |
* | ||
*/ | ||
import debounce from 'debounce' | ||
import { ref, nextTick, computed, watch, onBeforeUnmount } from 'vue' | ||
import { ref, nextTick, computed, watch, onBeforeUnmount, onMounted } from 'vue' | ||
|
||
import { subscribe, unsubscribe } from '@nextcloud/event-bus' | ||
|
||
|
@@ -32,8 +32,9 @@ import { EventBus } from '../services/EventBus.js' | |
|
||
/** | ||
* @param {import('vue').Ref} isActive whether the participants tab is active | ||
* @param {Boolean} isTopBar whether the component is the top bar | ||
Check warning on line 35 in src/composables/useGetParticipants.js GitHub Actions / NPM lint
|
||
*/ | ||
export function useGetParticipants(isActive = ref(true)) { | ||
export function useGetParticipants(isActive = ref(true), isTopBar = true) { | ||
|
||
// Encapsulation | ||
const store = useStore() | ||
|
@@ -48,7 +49,7 @@ export function useGetParticipants(isActive = ref(true)) { | |
const participantsInitialised = ref(false) | ||
|
||
/** | ||
* Initialise the get participants functionality | ||
* Initialise the get participants listeners | ||
* | ||
*/ | ||
function initialiseGetParticipants() { | ||
|
@@ -63,7 +64,7 @@ export function useGetParticipants(isActive = ref(true)) { | |
} | ||
|
||
/** | ||
* Stop the get participants functionality | ||
* Stop the get participants listeners | ||
* | ||
*/ | ||
function stopGetParticipants() { | ||
|
@@ -123,30 +124,26 @@ export function useGetParticipants(isActive = ref(true)) { | |
const debounceSlowUpdateParticipants = debounce( | ||
cancelableGetParticipants, 15000) | ||
|
||
// Group conversations have composable in RightSidebar, so should work only for one-to-one | ||
watch(isOneToOneConversation, (newValue) => { | ||
if (newValue) { | ||
onMounted(() => { | ||
if (isTopBar) { | ||
initialiseGetParticipants() | ||
} else { | ||
stopGetParticipants() | ||
} | ||
}, { immediate: true }) | ||
}) | ||
|
||
watch(isActive, (newValue) => { | ||
if (newValue && pendingChanges) { | ||
debounceUpdateParticipants() | ||
} | ||
}) | ||
|
||
onBeforeUnmount( | ||
() => { | ||
onBeforeUnmount(() => { | ||
if (isTopBar) { | ||
stopGetParticipants() | ||
} | ||
) | ||
}) | ||
|
||
return { | ||
participantsInitialised, | ||
initialiseGetParticipants, | ||
cancelableGetParticipants, | ||
} | ||
} |