diff --git a/components/core/Filter/Filters.js b/components/core/Filter/Filters.js index fe40f580..f4496ddd 100644 --- a/components/core/Filter/Filters.js +++ b/components/core/Filter/Filters.js @@ -1,6 +1,7 @@ import * as React from "react"; import * as SVG from "~/common/svg"; import * as Styles from "~/common/styles"; +import * as Events from "~/common/custom-events"; import * as Typography from "~/components/system/components/Typography"; import * as Utilities from "~/common/utilities"; @@ -145,11 +146,12 @@ function Profile({ viewer, data, page, onAction, ...props }) { setIsFollowing(updatedIsFollowing); }, [viewer?.following, data?.id]); - const handleFollow = async () => { + const handleFollow = async (newStatus) => { if (!isAuthenticated) { Events.dispatchCustomEvent({ name: "slate-global-open-cta", detail: {} }); return; } + setIsFollowing(newStatus); await Actions.createSubscription({ userId: data.id, }); @@ -182,8 +184,7 @@ function Profile({ viewer, data, page, onAction, ...props }) { { - setIsFollowing(false); - handleFollow(); + handleFollow(false); }} > Unfollow @@ -192,8 +193,7 @@ function Profile({ viewer, data, page, onAction, ...props }) { { - setIsFollowing(true); - handleFollow(); + handleFollow(true); }} > Follow diff --git a/pages/_/file.js b/pages/_/file.js index 5269d58a..cc4c161c 100644 --- a/pages/_/file.js +++ b/pages/_/file.js @@ -86,7 +86,7 @@ export default class ProfilePage extends React.Component { onAction={() => {}} isMobile={isMobile} // params={page.params} - isOwner={viewer.id === file.ownerId} + isOwner={viewer?.id === file.ownerId} index={0} onChange={() => {}} /> diff --git a/scenes/SceneFilesFolder.js b/scenes/SceneFilesFolder.js index 3c8ab9b8..1dcadc22 100644 --- a/scenes/SceneFilesFolder.js +++ b/scenes/SceneFilesFolder.js @@ -18,12 +18,12 @@ const STYLES_SCENE_PAGE = css` } `; -const STYLES_DATAVIEWER_WRAPPER = (theme) => css` +const STYLES_DATAVIEW_WRAPPER = (theme) => css` width: 100%; - min-height: calc(100vh - ${theme.sizes.filterNavbar}px); - padding: calc(20px + ${theme.sizes.filterNavbar}px) 24px 44px; + min-height: calc(100vh - ${theme.sizes.filterNavbar}px) - ${theme.sizes.header}px; + padding: 20px 20px 44px; @media (max-width: ${theme.sizes.mobile}px) { - padding: calc(31px + ${theme.sizes.filterNavbar}px) 16px 44px; + padding: 16px 16px 44px; } `; @@ -49,7 +49,7 @@ export default function SceneFilesFolder({ viewer, page, onAction, isMobile }) { index={index} onChange={(index) => setIndex(index)} /> -
+
{objects.length ? ( css` +const STYLES_DATAVIEW_WRAPPER = (theme) => css` width: 100%; - min-height: calc(100vh - ${theme.sizes.filterNavbar}px); - padding: calc(20px + ${theme.sizes.filterNavbar}px) 24px 44px; + min-height: calc(100vh - ${theme.sizes.filterNavbar}px) - ${theme.sizes.header}px; + padding: 20px 20px 44px; @media (max-width: ${theme.sizes.mobile}px) { - padding: calc(31px + ${theme.sizes.filterNavbar}px) 16px 44px; + padding: 16px 16px 44px; } `; @@ -199,7 +199,7 @@ export default class SceneProfile extends React.Component { url={`${Constants.hostname}${this.props.page.pathname}`} image={image} > -
+
{user.library?.length ? ( css` +const STYLES_DATAVIEW_WRAPPER = (theme) => css` width: 100%; - min-height: calc(100vh - ${theme.sizes.filterNavbar}px); - padding: calc(20px + ${theme.sizes.filterNavbar}px) 24px 44px; + min-height: calc(100vh - ${theme.sizes.filterNavbar}px) - ${theme.sizes.header}px; + padding: 20px 20px 44px; @media (max-width: ${theme.sizes.mobile}px) { - padding: calc(31px + ${theme.sizes.filterNavbar}px) 16px 44px; + padding: 16px 16px 44px; } `; @@ -452,7 +452,7 @@ class SlatePage extends React.Component { index={this.state.index} onChange={(index) => this.setState({ index })} /> -
+
{ const id = Utilities.getIdFromCookie(req); - let viewer = null; - if (id) { - viewer = await ViewerManager.getById({ - id, - }); - } - - let { page, redirected } = NavigationData.getByHref(req.path, viewer); - if (!redirected) { - page.params = req.query; - } - let user = await Data.getUserByUsername({ username, - sanitize: true, - includeFiles: true, - publicOnly: true, }); if (!user) { @@ -291,12 +276,34 @@ app.prepare().then(async () => { return res.redirect("/_/404"); } + if (user.id === id) { + return res.redirect("/_/data"); + } + const slates = await Data.getSlatesByUserId({ ownerId: user.id, publicOnly: true, }); - user.slates = slates; + if (slates && !slates.error) { + if (slates.length) { + return res.redirect(`/${username}/${slates[0].slatename}`); + } + + user.slates = slates; + } + + let viewer = null; + if (id) { + viewer = await Data.getUserById({ + id, + }); + } + + let { page, redirected } = NavigationData.getByHref(req.path, viewer); + if (!redirected) { + page.params = req.query; + } return app.render(req, res, "/_", { viewer,