mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-20 15:22:18 +00:00
🐛(frontend) fix PiP reactions rendering and shortcut ownership
Show reactions in PiP and prevent main shortcuts from overriding PiP.
This commit is contained in:
@@ -0,0 +1,51 @@
|
|||||||
|
import { useMemo, useRef } from 'react'
|
||||||
|
import { useSnapshot } from 'valtio'
|
||||||
|
import { css } from '@/styled-system/css'
|
||||||
|
import { reactionsStore } from '@/stores/reactions'
|
||||||
|
import { FloatingReaction } from '@/features/reactions/components/ReactionPortals'
|
||||||
|
import type { Reaction } from '@/features/reactions/types'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders floating emoji reactions inside the PiP window.
|
||||||
|
* Reads the same shared reactionsStore used by the main window.
|
||||||
|
*/
|
||||||
|
export const PipReactionPortals = () => {
|
||||||
|
const { reactions } = useSnapshot(reactionsStore)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{reactions.map((reaction) => (
|
||||||
|
<PipFloatingReaction key={reaction.id} reaction={reaction} />
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const PipFloatingReaction = ({ reaction }: { reaction: Reaction }) => {
|
||||||
|
const containerRef = useRef<HTMLDivElement>(null)
|
||||||
|
const speed = useMemo(() => Math.random() * 1.5 + 0.5, [])
|
||||||
|
const scale = useMemo(() => Math.max(Math.random() + 0.5, 1), [])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
ref={containerRef}
|
||||||
|
className={css({
|
||||||
|
position: 'absolute',
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
pointerEvents: 'none',
|
||||||
|
overflow: 'hidden',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<FloatingReaction
|
||||||
|
emoji={reaction.emoji}
|
||||||
|
speed={speed}
|
||||||
|
scale={scale}
|
||||||
|
name={reaction.participantName}
|
||||||
|
isLocal={reaction.isLocal}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ import { PipReactionsToolbar } from './PipReactionsToolbar'
|
|||||||
import { PipStage } from './layouts/PipStage'
|
import { PipStage } from './layouts/PipStage'
|
||||||
import { PipNotificationOverlay } from './notifications/PipNotificationOverlay'
|
import { PipNotificationOverlay } from './notifications/PipNotificationOverlay'
|
||||||
import { PipConnectionStateToast } from './notifications/PipConnectionStateToast'
|
import { PipConnectionStateToast } from './notifications/PipConnectionStateToast'
|
||||||
|
import { PipReactionPortals } from './PipReactionPortals'
|
||||||
|
|
||||||
export const PipView = () => {
|
export const PipView = () => {
|
||||||
const browserSupportsScreenSharing = supportsScreenSharing()
|
const browserSupportsScreenSharing = supportsScreenSharing()
|
||||||
@@ -49,6 +50,7 @@ export const PipView = () => {
|
|||||||
<PipReactionsToolbar />
|
<PipReactionsToolbar />
|
||||||
<PipControlBar showScreenShare={browserSupportsScreenSharing} />
|
<PipControlBar showScreenShare={browserSupportsScreenSharing} />
|
||||||
<SidePanel store={pipLayoutStore} />
|
<SidePanel store={pipLayoutStore} />
|
||||||
|
<PipReactionPortals />
|
||||||
<OverlayStack>
|
<OverlayStack>
|
||||||
<PipConnectionStateToast />
|
<PipConnectionStateToast />
|
||||||
<PipNotificationOverlay />
|
<PipNotificationOverlay />
|
||||||
|
|||||||
@@ -56,15 +56,14 @@ export const PipReactionsPill = ({ isOpen, availableWidth }: Props) => {
|
|||||||
<Pill isVisible={isVisible}>
|
<Pill isVisible={isVisible}>
|
||||||
{hasOverflow && (
|
{hasOverflow && (
|
||||||
<ArrowSlot>
|
<ArrowSlot>
|
||||||
{canGoLeft && (
|
<ArrowButton
|
||||||
<ArrowButton
|
type="button"
|
||||||
type="button"
|
onClick={() => paginate('left')}
|
||||||
onClick={() => paginate('left')}
|
aria-label={t('previousReactions')}
|
||||||
aria-label={t('previousReactions')}
|
disabled={!canGoLeft}
|
||||||
>
|
>
|
||||||
<RiArrowLeftSLine size={16} />
|
<RiArrowLeftSLine size={16} />
|
||||||
</ArrowButton>
|
</ArrowButton>
|
||||||
)}
|
|
||||||
</ArrowSlot>
|
</ArrowSlot>
|
||||||
)}
|
)}
|
||||||
<EmojiRow>
|
<EmojiRow>
|
||||||
@@ -74,15 +73,14 @@ export const PipReactionsPill = ({ isOpen, availableWidth }: Props) => {
|
|||||||
</EmojiRow>
|
</EmojiRow>
|
||||||
{hasOverflow && (
|
{hasOverflow && (
|
||||||
<ArrowSlot>
|
<ArrowSlot>
|
||||||
{canGoRight && (
|
<ArrowButton
|
||||||
<ArrowButton
|
type="button"
|
||||||
type="button"
|
onClick={() => paginate('right')}
|
||||||
onClick={() => paginate('right')}
|
aria-label={t('nextReactions')}
|
||||||
aria-label={t('nextReactions')}
|
disabled={!canGoRight}
|
||||||
>
|
>
|
||||||
<RiArrowRightSLine size={16} />
|
<RiArrowRightSLine size={16} />
|
||||||
</ArrowButton>
|
</ArrowButton>
|
||||||
)}
|
|
||||||
</ArrowSlot>
|
</ArrowSlot>
|
||||||
)}
|
)}
|
||||||
</Pill>
|
</Pill>
|
||||||
@@ -156,5 +154,10 @@ const ArrowButton = styled('button', {
|
|||||||
opacity: 1,
|
opacity: 1,
|
||||||
backgroundColor: 'primaryDark.300',
|
backgroundColor: 'primaryDark.300',
|
||||||
},
|
},
|
||||||
|
_disabled: {
|
||||||
|
opacity: 0.3,
|
||||||
|
cursor: 'default',
|
||||||
|
pointerEvents: 'none',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { useRegisterKeyboardShortcut } from '@/features/shortcuts/useRegisterKey
|
|||||||
import { REACTIONS_TOOLBAR_ID } from '../constants'
|
import { REACTIONS_TOOLBAR_ID } from '../constants'
|
||||||
import { useReactionsToolbar } from '../hooks/useReactionsToolbar'
|
import { useReactionsToolbar } from '../hooks/useReactionsToolbar'
|
||||||
import { layoutStore } from '@/stores/layout'
|
import { layoutStore } from '@/stores/layout'
|
||||||
|
import { useRoomPiP } from '@/features/pip/hooks/useRoomPiP'
|
||||||
|
|
||||||
const focusReactionsToolbar = () => {
|
const focusReactionsToolbar = () => {
|
||||||
document
|
document
|
||||||
@@ -17,6 +18,7 @@ const focusReactionsToolbar = () => {
|
|||||||
|
|
||||||
export const ReactionsToggle = () => {
|
export const ReactionsToggle = () => {
|
||||||
const { t } = useTranslation('rooms', { keyPrefix: 'controls.reactions' })
|
const { t } = useTranslation('rooms', { keyPrefix: 'controls.reactions' })
|
||||||
|
const { isOpen: isPiPOpen } = useRoomPiP()
|
||||||
|
|
||||||
const { isOpen, toggle } = useReactionsToolbar()
|
const { isOpen, toggle } = useReactionsToolbar()
|
||||||
|
|
||||||
@@ -31,6 +33,7 @@ export const ReactionsToggle = () => {
|
|||||||
useRegisterKeyboardShortcut({
|
useRegisterKeyboardShortcut({
|
||||||
id: 'reaction',
|
id: 'reaction',
|
||||||
handler: handleShortcut,
|
handler: handleShortcut,
|
||||||
|
isDisabled: isPiPOpen,
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -16,17 +16,20 @@ import { VideoDeviceControl } from '../../components/controls/Device/VideoDevice
|
|||||||
import { AudioDevicesControl } from '../../components/controls/Device/AudioDevicesControl'
|
import { AudioDevicesControl } from '../../components/controls/Device/AudioDevicesControl'
|
||||||
import { ReactionsToggle } from '@/features/reactions/components/ReactionsToggle'
|
import { ReactionsToggle } from '@/features/reactions/components/ReactionsToggle'
|
||||||
import { ControlBarRegion } from '@/features/layout/components/ControlBarRegion'
|
import { ControlBarRegion } from '@/features/layout/components/ControlBarRegion'
|
||||||
|
import { useRoomPiP } from '@/features/pip/hooks/useRoomPiP'
|
||||||
|
|
||||||
export function DesktopControlBar({
|
export function DesktopControlBar({
|
||||||
onDeviceError,
|
onDeviceError,
|
||||||
}: Readonly<ControlBarAuxProps>) {
|
}: Readonly<ControlBarAuxProps>) {
|
||||||
const browserSupportsScreenSharing = supportsScreenSharing()
|
const browserSupportsScreenSharing = supportsScreenSharing()
|
||||||
const desktopControlBarEl = useRef<HTMLDivElement>(null)
|
const desktopControlBarEl = useRef<HTMLDivElement>(null)
|
||||||
|
const { isOpen: isPiPOpen } = useRoomPiP()
|
||||||
|
|
||||||
const { toggleFullScreen, isFullscreenAvailable } = useFullScreen({})
|
const { toggleFullScreen, isFullscreenAvailable } = useFullScreen({})
|
||||||
|
|
||||||
useRegisterKeyboardShortcut({
|
useRegisterKeyboardShortcut({
|
||||||
id: 'focus-toolbar',
|
id: 'focus-toolbar',
|
||||||
|
isDisabled: isPiPOpen,
|
||||||
handler: () => {
|
handler: () => {
|
||||||
const root = desktopControlBarEl.current
|
const root = desktopControlBarEl.current
|
||||||
if (!root) return
|
if (!root) return
|
||||||
|
|||||||
@@ -19,10 +19,14 @@ export const useRegisterKeyboardShortcut = ({
|
|||||||
const descriptor = getShortcutDescriptorById(id)
|
const descriptor = getShortcutDescriptorById(id)
|
||||||
if (!descriptor?.shortcut) return
|
if (!descriptor?.shortcut) return
|
||||||
const formattedKey = formatShortcutKey(descriptor.shortcut)
|
const formattedKey = formatShortcutKey(descriptor.shortcut)
|
||||||
if (isDisabled) {
|
if (!isDisabled) {
|
||||||
keyboardShortcutsStore.shortcuts.delete(formattedKey)
|
|
||||||
} else {
|
|
||||||
keyboardShortcutsStore.shortcuts.set(formattedKey, handler)
|
keyboardShortcutsStore.shortcuts.set(formattedKey, handler)
|
||||||
}
|
}
|
||||||
|
return () => {
|
||||||
|
// Remove only if this is still the registered handler
|
||||||
|
if (keyboardShortcutsStore.shortcuts.get(formattedKey) === handler) {
|
||||||
|
keyboardShortcutsStore.shortcuts.delete(formattedKey)
|
||||||
|
}
|
||||||
|
}
|
||||||
}, [handler, id, isDisabled])
|
}, [handler, id, isDisabled])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user