From 6f5f43205ab24f20350e72883c63ddf768525700 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 18 Nov 2025 23:40:41 +0100 Subject: [PATCH] fix(session): Mark session as inactive when blurring the window Signed-off-by: Joas Schilling --- docs/settings.md | 10 ++++++---- src/composables/useActiveSession.js | 18 ++++++++++++------ src/constants.ts | 5 +++++ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/docs/settings.md b/docs/settings.md index 9a2589d6062..988dba70124 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -139,7 +139,9 @@ Legend: Features that can be toggled on-off with the `experiments_users` and `experiments_guests` bit flags: -| Bit | Status | Introduced | Ended | Description | -|-----|--------|----------------------------------|-------|-----------------------------------------------------------------------------------------------------------------------------| -| 1 | Active | Web 21.1.0
Desktop 1.2.2-beta | - | Instead of refreshing the participant list repeatingly during calls, the data is generated from received signaling messages | -| 2 | Active | Web 21.1.0
Desktop 1.2.2 | - | Make automatic attempts to recover suspended / expired signaling session to allow join the call without page reload | +| Bit | Status | Introduced | Ended | Description | +|-----|--------|----------------------------------|-------------------------|-----------------------------------------------------------------------------------------------------------------------------| +| 1 | Active | Web 21.1.0
Desktop 1.2.2-beta | - | Instead of refreshing the participant list repeatingly during calls, the data is generated from received signaling messages | +| 2 | Active | Web 21.1.0
Desktop 1.2.2 | - | Make automatic attempts to recover suspended / expired signaling session to allow join the call without page reload | +| 4 | Ended | Web 22.0.3
Desktop 2.0.4 | Web 23.0
Desktop 3.0 | Send chat messages via the High performance-backend / websocket | +| 8 | Active | Web 22.0.3
Desktop 2.0.4 | - | Mark sessions immediately as inactive when switching away from Talk | diff --git a/src/composables/useActiveSession.js b/src/composables/useActiveSession.js index f0a17cf91f1..f4e206af96e 100644 --- a/src/composables/useActiveSession.js +++ b/src/composables/useActiveSession.js @@ -6,6 +6,7 @@ import { computed, onBeforeMount, onBeforeUnmount, ref, watch } from 'vue' import { useStore } from 'vuex' import { CONFIG, SESSION } from '../constants.ts' +import BrowserStorage from '../services/BrowserStorage.js' import { getTalkConfig, hasTalkFeature } from '../services/CapabilitiesManager.ts' import { setSessionState } from '../services/participantsService.js' import { useTokenStore } from '../stores/token.ts' @@ -16,6 +17,7 @@ import { useIsInCall } from './useIsInCall.js' const INACTIVE_TIME_MS = 3 * 60 * 1000 const experimentalRecoverSession = (getTalkConfig('local', 'experiments', 'enabled') ?? 0) & CONFIG.EXPERIMENTAL.RECOVER_SESSION +const experimentalInactiveOnBlur = (getTalkConfig('local', 'experiments', 'enabled') ?? 0) & CONFIG.EXPERIMENTAL.SESSION_INACTIVE_ON_BLUR /** * Check whether the current session is active or not: @@ -123,13 +125,17 @@ export function useActiveSession() { document.body.removeEventListener('mouseenter', handleMouseEnter) document.body.removeEventListener('mouseleave', handleMouseLeave) } else if (type === 'blur') { - inactiveTimer.value = setTimeout(() => { + if (!experimentalInactiveOnBlur || BrowserStorage.getItem('pause-notification-on-blur') === 'yes') { + inactiveTimer.value = setTimeout(() => { + setSessionAsInactive() + }, INACTIVE_TIME_MS) + + // Listen for mouse events to track activity on tab + document.body.addEventListener('mouseenter', handleMouseEnter) + document.body.addEventListener('mouseleave', handleMouseLeave) + } else { setSessionAsInactive() - }, INACTIVE_TIME_MS) - - // Listen for mouse events to track activity on tab - document.body.addEventListener('mouseenter', handleMouseEnter) - document.body.addEventListener('mouseleave', handleMouseLeave) + } } } diff --git a/src/constants.ts b/src/constants.ts index 0905cba3e5a..9d889f44a58 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -27,6 +27,11 @@ export const CONFIG = { * Send chat messages via the High performance-backend / websocket */ CHAT_RELAY: 4, + /** + * Since 22.0.3 + * Mark sessions immediately as inactive when switching away from Talk + */ + SESSION_INACTIVE_ON_BLUR: 8, }, } as const