mirror of
https://github.com/filecoin-project/slate.git
synced 2024-10-26 22:39:39 +03:00
added default to first slate in a profile, and redirect to data for own profile
This commit is contained in:
parent
3c290bf0e1
commit
c0f918f8c6
@ -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 }) {
|
||||
<ButtonSecondary
|
||||
full
|
||||
onClick={() => {
|
||||
setIsFollowing(false);
|
||||
handleFollow();
|
||||
handleFollow(false);
|
||||
}}
|
||||
>
|
||||
Unfollow
|
||||
@ -192,8 +193,7 @@ function Profile({ viewer, data, page, onAction, ...props }) {
|
||||
<ButtonPrimary
|
||||
full
|
||||
onClick={() => {
|
||||
setIsFollowing(true);
|
||||
handleFollow();
|
||||
handleFollow(true);
|
||||
}}
|
||||
>
|
||||
Follow
|
||||
|
@ -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={() => {}}
|
||||
/>
|
||||
|
@ -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)}
|
||||
/>
|
||||
<div css={STYLES_DATAVIEWER_WRAPPER}>
|
||||
<div css={STYLES_DATAVIEW_WRAPPER}>
|
||||
{objects.length ? (
|
||||
<DataView
|
||||
key="scene-files-folder"
|
||||
|
@ -23,12 +23,12 @@ const STYLES_LOADER = css`
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
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;
|
||||
}
|
||||
`;
|
||||
|
||||
@ -199,7 +199,7 @@ export default class SceneProfile extends React.Component {
|
||||
url={`${Constants.hostname}${this.props.page.pathname}`}
|
||||
image={image}
|
||||
>
|
||||
<div css={STYLES_DATAVIEWER_WRAPPER}>
|
||||
<div css={STYLES_DATAVIEW_WRAPPER}>
|
||||
{user.library?.length ? (
|
||||
<DataView
|
||||
key="scene-files-folder"
|
||||
|
@ -268,12 +268,12 @@ const STYLES_RESET_SCENE_PAGE_PADDING = 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;
|
||||
}
|
||||
`;
|
||||
|
||||
@ -452,7 +452,7 @@ class SlatePage extends React.Component {
|
||||
index={this.state.index}
|
||||
onChange={(index) => this.setState({ index })}
|
||||
/>
|
||||
<div css={STYLES_DATAVIEWER_WRAPPER}>
|
||||
<div css={STYLES_DATAVIEW_WRAPPER}>
|
||||
<DataView
|
||||
key="scene-files-folder"
|
||||
type="collection"
|
||||
|
39
server.js
39
server.js
@ -264,23 +264,8 @@ app.prepare().then(async () => {
|
||||
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user