|
|
|
|
@@ -5,6 +5,7 @@ import FocusTrap from 'focus-trap-react';
|
|
|
|
|
import {
|
|
|
|
|
Avatar,
|
|
|
|
|
Box,
|
|
|
|
|
Button,
|
|
|
|
|
Header,
|
|
|
|
|
Icon,
|
|
|
|
|
IconButton,
|
|
|
|
|
@@ -62,6 +63,7 @@ export function ShareRoomPicker({ share, onPick, onDismiss }: ShareRoomPickerPro
|
|
|
|
|
const mx = useMatrixClient();
|
|
|
|
|
const useAuthentication = useMediaAuthentication();
|
|
|
|
|
const scrollRef = useRef<HTMLDivElement>(null);
|
|
|
|
|
const [confirmRoomId, setConfirmRoomId] = useState<string | null>(null);
|
|
|
|
|
|
|
|
|
|
const mDirects = useAtomValue(mDirectAtom);
|
|
|
|
|
const allRoomsSet = useAllJoinedRoomsSet();
|
|
|
|
|
@@ -107,16 +109,25 @@ export function ShareRoomPicker({ share, onPick, onDismiss }: ShareRoomPickerPro
|
|
|
|
|
const handleRoomClick: React.MouseEventHandler<HTMLButtonElement> = (evt) => {
|
|
|
|
|
const roomId = evt.currentTarget.getAttribute('data-room-id');
|
|
|
|
|
if (roomId) {
|
|
|
|
|
onPick(roomId);
|
|
|
|
|
setConfirmRoomId(roomId);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleConfirm = useCallback(() => {
|
|
|
|
|
if (confirmRoomId) {
|
|
|
|
|
onPick(confirmRoomId);
|
|
|
|
|
}
|
|
|
|
|
}, [confirmRoomId, onPick]);
|
|
|
|
|
|
|
|
|
|
const handleCancelConfirm = useCallback(() => {
|
|
|
|
|
setConfirmRoomId(null);
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const previewText = share.text?.slice(0, 80) ?? share.subject?.slice(0, 80);
|
|
|
|
|
const fileCount = share.files.length;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Overlay open backdrop={<OverlayBackdrop />}>
|
|
|
|
|
<OverlayCenter>
|
|
|
|
|
<FocusTrap
|
|
|
|
|
focusTrapOptions={{
|
|
|
|
|
initialFocus: false,
|
|
|
|
|
@@ -125,11 +136,19 @@ export function ShareRoomPicker({ share, onPick, onDismiss }: ShareRoomPickerPro
|
|
|
|
|
escapeDeactivates: stopPropagation,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Modal size="300">
|
|
|
|
|
<Box grow="Yes" direction="Column" style={{ maxHeight: '85vh' }}>
|
|
|
|
|
<Box
|
|
|
|
|
grow="Yes"
|
|
|
|
|
direction="Column"
|
|
|
|
|
style={{
|
|
|
|
|
position: 'fixed',
|
|
|
|
|
inset: 0,
|
|
|
|
|
zIndex: 999,
|
|
|
|
|
backgroundColor: '#1a1d23',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Header
|
|
|
|
|
size="500"
|
|
|
|
|
style={{ padding: config.space.S200, paddingLeft: config.space.S400 }}
|
|
|
|
|
style={{ padding: config.space.S400, paddingTop: '60px' }}
|
|
|
|
|
>
|
|
|
|
|
<Box grow="Yes" direction="Column" gap="100">
|
|
|
|
|
<Text size="H4">Share to Room</Text>
|
|
|
|
|
@@ -150,9 +169,7 @@ export function ShareRoomPicker({ share, onPick, onDismiss }: ShareRoomPickerPro
|
|
|
|
|
|
|
|
|
|
<Box
|
|
|
|
|
style={{
|
|
|
|
|
padding: `0 ${config.space.S300}`,
|
|
|
|
|
paddingTop: config.space.S200,
|
|
|
|
|
paddingBottom: config.space.S200,
|
|
|
|
|
padding: config.space.S200,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Input
|
|
|
|
|
@@ -163,14 +180,12 @@ export function ShareRoomPicker({ share, onPick, onDismiss }: ShareRoomPickerPro
|
|
|
|
|
variant="Background"
|
|
|
|
|
outlined
|
|
|
|
|
autoFocus
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
|
|
|
|
|
|
|
|
|
<Scroll ref={scrollRef} size="300" hideTrack style={{ flex: 1, minHeight: 0 }}>
|
|
|
|
|
<Box
|
|
|
|
|
style={{ padding: config.space.S300, paddingTop: 0 }}
|
|
|
|
|
direction="Column"
|
|
|
|
|
>
|
|
|
|
|
<Box style={{ padding: config.space.S300, paddingTop: config.space.S300 }} direction="Column">
|
|
|
|
|
{vItems.length === 0 && (
|
|
|
|
|
<Box
|
|
|
|
|
style={{ padding: `${config.space.S700} 0` }}
|
|
|
|
|
@@ -189,9 +204,7 @@ export function ShareRoomPicker({ share, onPick, onDismiss }: ShareRoomPickerPro
|
|
|
|
|
</Text>
|
|
|
|
|
</Box>
|
|
|
|
|
)}
|
|
|
|
|
<Box
|
|
|
|
|
style={{ position: 'relative', height: virtualizer.getTotalSize() }}
|
|
|
|
|
>
|
|
|
|
|
<Box style={{ position: 'relative', height: virtualizer.getTotalSize() }}>
|
|
|
|
|
{vItems.map((vItem) => {
|
|
|
|
|
const roomId = items[vItem.index];
|
|
|
|
|
const room = getRoom(roomId);
|
|
|
|
|
@@ -247,9 +260,51 @@ export function ShareRoomPicker({ share, onPick, onDismiss }: ShareRoomPickerPro
|
|
|
|
|
</Box>
|
|
|
|
|
</Scroll>
|
|
|
|
|
</Box>
|
|
|
|
|
</FocusTrap>
|
|
|
|
|
|
|
|
|
|
{confirmRoomId && (() => {
|
|
|
|
|
const room = getRoom(confirmRoomId);
|
|
|
|
|
const roomName = room?.name ?? confirmRoomId;
|
|
|
|
|
const isDm = mDirects.has(confirmRoomId);
|
|
|
|
|
return (
|
|
|
|
|
<OverlayCenter style={{ zIndex: 9999 }}>
|
|
|
|
|
<FocusTrap
|
|
|
|
|
focusTrapOptions={{
|
|
|
|
|
initialFocus: false,
|
|
|
|
|
onDeactivate: handleCancelConfirm,
|
|
|
|
|
escapeDeactivates: stopPropagation,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Modal size="300" style={{ zIndex: 9999 }}>
|
|
|
|
|
<Box direction="Column" gap="100" style={{ padding: config.space.S400 }}>
|
|
|
|
|
<Box direction="Column" gap="200">
|
|
|
|
|
<Text size="H4">Share to {isDm ? 'Person' : 'Room'}?</Text>
|
|
|
|
|
<Text size="T300" priority="300">
|
|
|
|
|
Send to <strong>{roomName}</strong>?
|
|
|
|
|
</Text>
|
|
|
|
|
</Box>
|
|
|
|
|
<Box gap="200" justifyContent="End">
|
|
|
|
|
<Button
|
|
|
|
|
onClick={handleCancelConfirm}
|
|
|
|
|
variant="Secondary"
|
|
|
|
|
size="400"
|
|
|
|
|
>
|
|
|
|
|
<Text size="B400">Cancel</Text>
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
onClick={handleConfirm}
|
|
|
|
|
variant="Primary"
|
|
|
|
|
size="400"
|
|
|
|
|
>
|
|
|
|
|
<Text size="B400">Share</Text>
|
|
|
|
|
</Button>
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
</Modal>
|
|
|
|
|
</FocusTrap>
|
|
|
|
|
</OverlayCenter>
|
|
|
|
|
);
|
|
|
|
|
})()}
|
|
|
|
|
</Overlay>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|