mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-25 01:52:45 +03:00
fixed bugs with navigating between profile slate pages
This commit is contained in:
parent
538b931309
commit
49c94daa47
@ -345,22 +345,23 @@ export default class ApplicationPage extends React.Component {
|
||||
state.activePage = page.id;
|
||||
}
|
||||
|
||||
let body = document.documentElement || document.body;
|
||||
if (page.id === "NAV_SLATE" || page.id === "NAV_PROFILE") {
|
||||
state.loading = true;
|
||||
state.data = { id: details.id };
|
||||
}
|
||||
this.setState(state, () => {
|
||||
if (!popstate) {
|
||||
body.scrollTo(0, 0);
|
||||
}
|
||||
if (page.id === "NAV_SLATE" || page.id === "NAV_PROFILE") {
|
||||
this.updateDataAndPathname({ page, details });
|
||||
}
|
||||
});
|
||||
if (page.id === "NAV_SLATE" || page.id === "NAV_PROFILE") {
|
||||
this.updateDataAndPathname({ page, details, state, popstate });
|
||||
} else {
|
||||
this.setState(state, () => {
|
||||
let body = document.documentElement || document.body;
|
||||
if (!popstate) {
|
||||
body.scrollTo(0, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
updateDataAndPathname = async ({ page, details }) => {
|
||||
updateDataAndPathname = async ({ page, details, state, popstate }) => {
|
||||
let pathname = page.pathname.split("?")[0];
|
||||
let search = Strings.getQueryStringFromParams(page.params);
|
||||
let data;
|
||||
@ -372,7 +373,7 @@ export default class ApplicationPage extends React.Component {
|
||||
return;
|
||||
}
|
||||
data = response.data;
|
||||
pathname = `/${data.user.username}/${data.slatename}${search}`;
|
||||
pathname = `/${data.owner.username}/${data.slatename}${search}`;
|
||||
} else if (page?.id === "NAV_PROFILE") {
|
||||
let response = await Actions.getSerializedProfile(details);
|
||||
if (!response || response.error) {
|
||||
@ -384,7 +385,12 @@ export default class ApplicationPage extends React.Component {
|
||||
pathname = `/${data.username}${search}`;
|
||||
}
|
||||
|
||||
this.setState({ data, loading: false });
|
||||
this.setState({ ...state, data, loading: false }, () => {
|
||||
if (!popstate) {
|
||||
let body = document.documentElement || document.body;
|
||||
body.scrollTo(0, 0);
|
||||
}
|
||||
});
|
||||
|
||||
window.history.replaceState(null, "Slate", pathname);
|
||||
};
|
||||
|
@ -120,6 +120,7 @@ function Tags({ viewer, data, onAction, ...props }) {
|
||||
}
|
||||
|
||||
function Profile({ viewer, data, page, onAction, ...props }) {
|
||||
console.log(data);
|
||||
if (page.id === "NAV_SLATE") {
|
||||
data = data.owner;
|
||||
}
|
||||
|
@ -58,7 +58,8 @@ const STYLES_SIDEBAR_FILTER_WRAPPER = (theme) => css`
|
||||
|
||||
export function Sidebar({ viewer, onAction, data, page, isMobile }) {
|
||||
const [{ sidebarState }] = useFilterContext();
|
||||
|
||||
console.log(data);
|
||||
console.log(page);
|
||||
if (!sidebarState.isVisible || isMobile) return null;
|
||||
|
||||
if (
|
||||
|
@ -42,7 +42,7 @@ export default async (req, res) => {
|
||||
|
||||
let slates = await Data.getSlatesByUserId({
|
||||
ownerId: user.id,
|
||||
// includeFiles: true,
|
||||
includeFiles: true,
|
||||
publicOnly: true,
|
||||
});
|
||||
|
||||
|
@ -188,7 +188,7 @@ export default class SceneProfile extends React.Component {
|
||||
{user.library?.length ? (
|
||||
<DataView
|
||||
key="scene-files-folder"
|
||||
isOwner={this.props.viewer.id === this.props.user.id}
|
||||
isOwner={isOwner}
|
||||
items={user.library}
|
||||
onAction={this.props.onAction}
|
||||
viewer={this.props.viewer}
|
||||
|
@ -279,6 +279,7 @@ app.prepare().then(async () => {
|
||||
let user = await Data.getUserByUsername({
|
||||
username,
|
||||
sanitize: true,
|
||||
includeFiles: true,
|
||||
publicOnly: true,
|
||||
});
|
||||
|
||||
@ -292,7 +293,6 @@ app.prepare().then(async () => {
|
||||
|
||||
const slates = await Data.getSlatesByUserId({
|
||||
ownerId: user.id,
|
||||
// includeFiles: true,
|
||||
publicOnly: true,
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user