mirror of
https://github.com/suitenumerique/meet.git
synced 2026-09-04 06:35:38 +00:00
fixup! ✨(frontend) introduce performance mode with auto-detection and telemetry
This commit is contained in:
@@ -49,12 +49,15 @@ export const collectHardwareSnapshot = async (): Promise<HardwareSnapshot> => {
|
|||||||
|
|
||||||
if (typeof nav.getBattery === 'function') {
|
if (typeof nav.getBattery === 'function') {
|
||||||
// getBattery can hang on some platforms — don't let it delay the event.
|
// getBattery can hang on some platforms — don't let it delay the event.
|
||||||
|
let timeoutId: ReturnType<typeof setTimeout> | undefined
|
||||||
const battery = await Promise.race([
|
const battery = await Promise.race([
|
||||||
nav.getBattery(),
|
nav.getBattery(),
|
||||||
new Promise<null>((resolve) =>
|
new Promise<null>((resolve) => {
|
||||||
setTimeout(() => resolve(null), BATTERY_TIMEOUT_MS)
|
timeoutId = setTimeout(() => resolve(null), BATTERY_TIMEOUT_MS)
|
||||||
),
|
}),
|
||||||
]).catch(() => null)
|
])
|
||||||
|
.catch(() => null)
|
||||||
|
.finally(() => clearTimeout(timeoutId))
|
||||||
if (battery) {
|
if (battery) {
|
||||||
snapshot.battery_level = battery.level
|
snapshot.battery_level = battery.level
|
||||||
snapshot.battery_charging = battery.charging
|
snapshot.battery_charging = battery.charging
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { useToast } from 'react-aria'
|
import { useToast } from 'react-aria'
|
||||||
import { useRef } from 'react'
|
import { useRef } from 'react'
|
||||||
|
import { RiCloseLine } from '@remixicon/react'
|
||||||
|
|
||||||
import { type ToastProps } from './Toast'
|
import { type ToastProps } from './Toast'
|
||||||
import { VStack } from '@/styled-system/jsx'
|
import { HStack, VStack } from '@/styled-system/jsx'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Button, Text } from '@/primitives'
|
import { Button, Text } from '@/primitives'
|
||||||
import { css } from '@/styled-system/css'
|
import { css } from '@/styled-system/css'
|
||||||
@@ -10,13 +11,16 @@ import { StyledToastContainer } from './StyledToastContainer'
|
|||||||
import { disablePerformanceMode } from '@/stores/performanceMode'
|
import { disablePerformanceMode } from '@/stores/performanceMode'
|
||||||
import { captureEvent } from '@/features/analytics/telemetry'
|
import { captureEvent } from '@/features/analytics/telemetry'
|
||||||
|
|
||||||
// todo - make it closable
|
|
||||||
export function ToastCpuConstrained({ state, ...props }: Readonly<ToastProps>) {
|
export function ToastCpuConstrained({ state, ...props }: Readonly<ToastProps>) {
|
||||||
const { t } = useTranslation('notifications', {
|
const { t } = useTranslation('notifications', {
|
||||||
keyPrefix: 'cpuConstrained',
|
keyPrefix: 'cpuConstrained',
|
||||||
})
|
})
|
||||||
const ref = useRef(null)
|
const ref = useRef(null)
|
||||||
const { toastProps, contentProps } = useToast(props, state, ref)
|
const { toastProps, contentProps, closeButtonProps } = useToast(
|
||||||
|
props,
|
||||||
|
state,
|
||||||
|
ref
|
||||||
|
)
|
||||||
const toast = props.toast
|
const toast = props.toast
|
||||||
|
|
||||||
const handleKeepQuality = () => {
|
const handleKeepQuality = () => {
|
||||||
@@ -27,35 +31,39 @@ export function ToastCpuConstrained({ state, ...props }: Readonly<ToastProps>) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledToastContainer {...toastProps} ref={ref}>
|
<StyledToastContainer {...toastProps} ref={ref}>
|
||||||
<VStack
|
<HStack alignItems="start" gap="0.5rem" padding={14}>
|
||||||
justify="start"
|
<VStack
|
||||||
alignItems="self-start"
|
justify="start"
|
||||||
{...contentProps}
|
alignItems="self-start"
|
||||||
maxWidth="370px"
|
{...contentProps}
|
||||||
gap="0.75rem"
|
maxWidth="370px"
|
||||||
padding={14}
|
gap="0.75rem"
|
||||||
>
|
|
||||||
<Text
|
|
||||||
margin={false}
|
|
||||||
className={css({
|
|
||||||
wordBreak: 'break-word',
|
|
||||||
overflowWrap: 'break-word',
|
|
||||||
whiteSpace: 'normal',
|
|
||||||
})}
|
|
||||||
>
|
>
|
||||||
{t('message')}
|
<Text
|
||||||
</Text>
|
margin={false}
|
||||||
<Button
|
className={css({
|
||||||
size="sm"
|
wordBreak: 'break-word',
|
||||||
variant="text"
|
overflowWrap: 'break-word',
|
||||||
className={css({
|
whiteSpace: 'normal',
|
||||||
color: 'primary.300',
|
})}
|
||||||
})}
|
>
|
||||||
onPress={() => handleKeepQuality()}
|
{t('message')}
|
||||||
>
|
</Text>
|
||||||
{t('keepQuality')}
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="text"
|
||||||
|
className={css({
|
||||||
|
color: 'primary.300',
|
||||||
|
})}
|
||||||
|
onPress={() => handleKeepQuality()}
|
||||||
|
>
|
||||||
|
{t('keepQuality')}
|
||||||
|
</Button>
|
||||||
|
</VStack>
|
||||||
|
<Button square size="sm" invisible {...closeButtonProps}>
|
||||||
|
<RiCloseLine size={18} color="white" />
|
||||||
</Button>
|
</Button>
|
||||||
</VStack>
|
</HStack>
|
||||||
</StyledToastContainer>
|
</StyledToastContainer>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user