diff --git a/components/core/Application.js b/components/core/Application.js index 0b3a02f3..6054ab43 100644 --- a/components/core/Application.js +++ b/components/core/Application.js @@ -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); }; diff --git a/components/core/Filter/Filters.js b/components/core/Filter/Filters.js index 38c3d3d1..a79ae6d4 100644 --- a/components/core/Filter/Filters.js +++ b/components/core/Filter/Filters.js @@ -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; } diff --git a/components/core/Filter/Sidebar.js b/components/core/Filter/Sidebar.js index 41f601db..b39a01c3 100644 --- a/components/core/Filter/Sidebar.js +++ b/components/core/Filter/Sidebar.js @@ -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 ( diff --git a/pages/api/users/get-serialized.js b/pages/api/users/get-serialized.js index 8857f12a..a9d39a7d 100644 --- a/pages/api/users/get-serialized.js +++ b/pages/api/users/get-serialized.js @@ -42,7 +42,7 @@ export default async (req, res) => { let slates = await Data.getSlatesByUserId({ ownerId: user.id, - // includeFiles: true, + includeFiles: true, publicOnly: true, }); diff --git a/scenes/SceneProfile.js b/scenes/SceneProfile.js index d16c784b..6ba09899 100644 --- a/scenes/SceneProfile.js +++ b/scenes/SceneProfile.js @@ -188,7 +188,7 @@ export default class SceneProfile extends React.Component { {user.library?.length ? ( { 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, });