From 7ebd24adaa66995b6664a663921367e4bf8da18e Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Tue, 5 Dec 2023 09:29:48 +0100 Subject: [PATCH] fix(activeSession): minor fixes - always reset timer on window focus change - do not set inactive state when in call Signed-off-by: Maksim Sukharev --- src/composables/useActiveSession.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/composables/useActiveSession.js b/src/composables/useActiveSession.js index 85b084c9304..0a4bdf81c62 100644 --- a/src/composables/useActiveSession.js +++ b/src/composables/useActiveSession.js @@ -24,6 +24,7 @@ import { showInfo } from '@nextcloud/dialogs' import { SESSION } from '../constants.js' import { setSessionState } from '../services/participantsService.js' +import { useIsInCall } from './useIsInCall.js' import { useStore } from './useStore.js' const supportSessionState = getCapabilities()?.spreed?.features?.includes('session-state') @@ -42,6 +43,7 @@ export function useActiveSession() { } const store = useStore() + const isInCall = useIsInCall() const token = computed(() => store.getters.getToken()) const windowIsVisible = computed(() => store.getters.windowIsVisible()) @@ -94,6 +96,9 @@ export function useActiveSession() { || !token.value) { return } + if (isInCall.value) { + return + } clearTimeout(inactiveTimer.value) inactiveTimer.value = null currentState.value = SESSION.STATE.INACTIVE @@ -111,13 +116,13 @@ export function useActiveSession() { } const handleWindowFocus = ({ type }) => { + clearTimeout(inactiveTimer.value) if (type === 'focus') { setSessionAsActive() document.removeEventListener('mouseenter', handleMouseMove) document.removeEventListener('mouseleave', handleMouseMove) } else if (type === 'blur') { - clearTimeout(inactiveTimer.value) inactiveTimer.value = setTimeout(() => { setSessionAsInactive() }, INACTIVE_TIME_MS)