fix: activities make chrome crash;

This commit is contained in:
mitsuhatu
2022-07-28 15:36:44 +08:00
parent ca7abcbdbe
commit 986b9f45a4

View File

@@ -45,23 +45,27 @@ const StyledWrapper = styled('div')({
}); });
export const Activities = () => { export const Activities = () => {
const navigate = useNavigate();
const { user, currentSpaceId } = useUserAndSpaces(); const { user, currentSpaceId } = useUserAndSpaces();
const [recenPages, setRecentPages] = useState([]); const [recentPages, setRecentPages] = useState([]);
const userId = user?.id;
const fetchRecentPages = useCallback(async () => { const fetchRecentPages = useCallback(async () => {
if (!user || !currentSpaceId) { if (!userId || !currentSpaceId) {
return; return;
} }
const recent_pages = await services.api.userConfig.getRecentPages( const recent_pages = await services.api.userConfig.getRecentPages(
currentSpaceId, currentSpaceId,
user.id userId
); );
setRecentPages(recent_pages); setRecentPages(recent_pages);
}, [user, currentSpaceId]); }, [userId, currentSpaceId]);
useEffect(() => { useEffect(() => {
fetchRecentPages(); (async () => {
}, [user, currentSpaceId]); await fetchRecentPages();
})();
}, [fetchRecentPages]);
useEffect(() => { useEffect(() => {
let unobserve: () => void; let unobserve: () => void;
@@ -80,12 +84,10 @@ export const Activities = () => {
}; };
}, [currentSpaceId, fetchRecentPages]); }, [currentSpaceId, fetchRecentPages]);
const navigate = useNavigate();
return ( return (
<StyledWrapper> <StyledWrapper>
<List> <List>
{recenPages.map(({ id, title, lastOpenTime }) => { {recentPages.map(({ id, title, lastOpenTime }) => {
return ( return (
<ListItem className="item" key={id}> <ListItem className="item" key={id}>
<ListItemButton <ListItemButton