messages: PR fixes

fixes urbit/landscape#497
This commit is contained in:
James Acklin 2021-04-20 20:43:20 -04:00
parent 378c826239
commit d7bee178c8

View File

@ -1,4 +1,4 @@
import React, { ReactElement, ReactNode, useRef, useEffect, useState } from 'react'; import React, { ReactElement, ReactNode, useState, useCallback } from 'react';
import { Icon, Box, Col, Text } from '@tlon/indigo-react'; import { Icon, Box, Col, Text } from '@tlon/indigo-react';
import styled from 'styled-components'; import styled from 'styled-components';
import { Link, useHistory } from 'react-router-dom'; import { Link, useHistory } from 'react-router-dom';
@ -37,7 +37,7 @@ export function ResourceSkeleton(props: ResourceSkeletonProps): ReactElement {
const groups = useGroupState(state => state.groups); const groups = useGroupState(state => state.groups);
const group = groups[association.group]; const group = groups[association.group];
let workspace = association.group; let workspace = association.group;
const actionsRef = useRef(null); const history = useHistory();
const [actionsWidth, setActionsWidth] = useState(0); const [actionsWidth, setActionsWidth] = useState(0);
if (group?.hidden && app === 'chat') { if (group?.hidden && app === 'chat') {
@ -182,11 +182,9 @@ export function ResourceSkeleton(props: ResourceSkeletonProps): ReactElement {
</Link> </Link>
); );
useEffect(() => { const actionsRef = useCallback((actionsRef) => {
if (actionsRef.current) { setActionsWidth(actionsRef?.getBoundingClientRect().width);
setActionsWidth(actionsRef.current.clientWidth); }, []);
}
}, [actionsRef]);
return ( return (
<Col width='100%' height='100%' overflow='hidden'> <Col width='100%' height='100%' overflow='hidden'>
@ -218,7 +216,7 @@ export function ResourceSkeleton(props: ResourceSkeletonProps): ReactElement {
flexShrink='0' flexShrink='0'
ref={actionsRef} ref={actionsRef}
> >
<ExtraControls /> {ExtraControls()}
<MenuControl /> <MenuControl />
</Box> </Box>
</Box> </Box>