Compare commits

...

3 Commits

Author SHA1 Message Date
lebaudantoine c5e6953add ♿️(frontend) keep floating reactions in place under reduced motion
The global prefers-reduced-motion rule only disables CSS animations
and transitions. A floating reaction is animated from script, so it
kept rising across the screen for users who asked for less motion.

Read the preference when the animation starts. When it is set, the
reaction stays where it appears and only fades out, over the same
duration.
2026-11-20 18:30:17 +01:00
lebaudantoine 3036973f9f 🐛(frontend) subscribe useRoomData to the query cache
useRoomData read the room with getQueryData during render, without
subscribing. Consumers only updated because Conference observes the
same query and re-renders its subtree, so a consumer behind a memoized
component kept a stale value after a room settings or LiveKit metadata
update.

Subscribe to the query cache with useSyncExternalStore, filtered on
the room entry. The hook stays a passive reader: it adds no observer,
so it never fetches nor hands its own options to the query.
2026-11-20 18:30:17 +01:00
lebaudantoine c0425dff11 ⚡️(frontend) animate floating reactions without rendering each frame
A floating reaction updated two states in requestAnimationFrame: the
component was rendered again on every frame, about 180 times during
the three seconds of its course, and moving it through its bottom
offset laid it out each time. A burst of reactions multiplies this by
the number of reactions on screen, during the call.

Describe the same course with the Web Animations API instead: a rise
at constant speed, with a fade out over the last 30 % of the course.
The browser runs it, the component is rendered once, and only the
transform and the opacity change.
2026-11-20 16:43:34 +01:00
3 changed files with 47 additions and 28 deletions
+3
View File
@@ -52,6 +52,9 @@ and this project adheres to
- ♿️(frontend) use a heading for every connection test card title
- ♿️(frontend) put the ProConnect link label inside the link
- 🔒️(frontend) bump nginx to 1.31.9 (CERT-EU 2026-022)
- ⚡️(frontend) animate floating reactions without rendering each frame
- 🐛(frontend) subscribe useRoomData to the query cache
- ♿️(frontend) keep floating reactions in place under reduced motion
## [1.37.0] - 2026-11-01
@@ -1,5 +1,5 @@
import { createPortal } from 'react-dom'
import { useState, useEffect } from 'react'
import { useState, useEffect, useRef } from 'react'
import { Text } from '@/primitives'
import { css } from '@/styled-system/css'
import { useSnapshot } from 'valtio'
@@ -29,39 +29,38 @@ export function FloatingReaction({
speed = 1,
scale = 1,
}: FloatingReactionProps) {
const [deltaY, setDeltaY] = useState(0)
const [opacity, setOpacity] = useState(1)
const elementRef = useRef<HTMLDivElement>(null)
const [left] = useState(
() => Math.random() * window.innerWidth * REACTION_SPAWN_WIDTH_RATIO
)
useEffect(() => {
let start: number | null = null
function animate(timestamp: number) {
if (start === null) start = timestamp
const elapsed = timestamp - start
if (elapsed < 0) {
setOpacity(0)
} else {
const progress = Math.min(elapsed / ANIMATION_DURATION, 1)
const distance = ANIMATION_DISTANCE * speed
const newY = progress * distance
setDeltaY(newY)
if (progress > FADE_OUT_THRESHOLD) {
setOpacity(1 - (progress - FADE_OUT_THRESHOLD) / 0.3)
}
}
if (elapsed < ANIMATION_DURATION) {
requestAnimationFrame(animate)
}
}
const req = requestAnimationFrame(animate)
return () => cancelAnimationFrame(req)
const element = elementRef.current
if (!element) return
const prefersReducedMotion = window.matchMedia(
'(prefers-reduced-motion: reduce)'
).matches
const distance = prefersReducedMotion ? 0 : ANIMATION_DISTANCE * speed
const animation = element.animate(
[
{ transform: 'translateY(0)', opacity: 1 },
{
transform: `translateY(${-distance * FADE_OUT_THRESHOLD}px)`,
opacity: 1,
offset: FADE_OUT_THRESHOLD,
},
{ transform: `translateY(${-distance}px)`, opacity: 0 },
],
{ duration: ANIMATION_DURATION, easing: 'linear', fill: 'forwards' }
)
return () => animation.cancel()
}, [speed])
return (
<div
ref={elementRef}
className={css({
position: 'absolute',
display: 'flex',
@@ -70,8 +69,7 @@ export function FloatingReaction({
})}
style={{
left: left,
bottom: INITIAL_POSITION + deltaY,
opacity: opacity,
bottom: INITIAL_POSITION,
}}
>
<img
@@ -1,3 +1,5 @@
import { useCallback, useSyncExternalStore } from 'react'
import { hashKey, notifyManager } from '@tanstack/react-query'
import type { ApiRoom } from '@/features/rooms/api/ApiRoom'
import { useParams } from 'wouter'
import { keys } from '@/api/queryKeys'
@@ -5,6 +7,22 @@ import { queryClient } from '@/api/queryClient'
export const useRoomData = (): ApiRoom | undefined => {
const { roomId } = useParams()
const queryKey = [keys.room, roomId]
return queryClient.getQueryData<ApiRoom>(queryKey)
const subscribe = useCallback(
(onStoreChange: () => void) => {
const queryHash = hashKey([keys.room, roomId])
const notify = notifyManager.batchCalls(onStoreChange)
return queryClient.getQueryCache().subscribe((event) => {
if (event.query.queryHash === queryHash) notify()
})
},
[roomId]
)
const getSnapshot = useCallback(
() => queryClient.getQueryData<ApiRoom>([keys.room, roomId]),
[roomId]
)
return useSyncExternalStore(subscribe, getSnapshot)
}