diff --git a/ui/src/Pages/SharePage/AlbumSharePage.tsx b/ui/src/Pages/SharePage/AlbumSharePage.tsx index ae6eef8..8d132f8 100644 --- a/ui/src/Pages/SharePage/AlbumSharePage.tsx +++ b/ui/src/Pages/SharePage/AlbumSharePage.tsx @@ -1,6 +1,8 @@ -import React from 'react' +import React, { useContext, useEffect, useRef } from 'react' import Layout from '../../components/layout/Layout' import AlbumGallery from '../../components/albumGallery/AlbumGallery' +import { SidebarContext } from '../../components/sidebar/Sidebar' +import MediaSidebar from '../../components/sidebar/MediaSidebar/MediaSidebar' import styled from 'styled-components' import { gql, useQuery } from '@apollo/client' import { useTranslation } from 'react-i18next' @@ -103,6 +105,9 @@ type AlbumSharePageProps = { const AlbumSharePage = ({ albumID, token, password }: AlbumSharePageProps) => { const { t } = useTranslation() + const { updateSidebar } = useContext(SidebarContext) + const openedAlbumID = useRef(null) + const urlParams = useURLParameters() const orderParams = useOrderingParams( urlParams, @@ -133,12 +138,23 @@ const AlbumSharePage = ({ albumID, token, password }: AlbumSharePageProps) => { getItems: data => data.album.media, }) + const album = data?.album + + // Open the detail sidebar with the first (newest) photo when the page loads. + useEffect(() => { + if (!album || openedAlbumID.current === album.id) return + + const firstMedia = album.media[0] + if (!firstMedia) return + + openedAlbumID.current = album.id + updateSidebar() + }, [album, updateSidebar]) + if (error) { return
{error.message}
} - const album = data?.album - return ( {

diff --git a/ui/src/components/layout/Layout.tsx b/ui/src/components/layout/Layout.tsx index 1f075f9..fe7a6f9 100644 --- a/ui/src/components/layout/Layout.tsx +++ b/ui/src/components/layout/Layout.tsx @@ -37,7 +37,7 @@ const Layout = ({ children, title, ...otherProps }: LayoutProps) => {
diff --git a/ui/src/components/messages/Messages.tsx b/ui/src/components/messages/Messages.tsx index 606544c..d65cccd 100644 --- a/ui/src/components/messages/Messages.tsx +++ b/ui/src/components/messages/Messages.tsx @@ -11,7 +11,7 @@ const Container = styled.div` bottom: 20px; right: 20px; /* Match the sidebar width */ - width: 420px; + width: 380px; /* Keep notifications above the sidebar (z-40) and modals (z-40) */ z-index: 50; diff --git a/ui/src/components/sidebar/Sidebar.tsx b/ui/src/components/sidebar/Sidebar.tsx index 4e052a6..ce169e7 100644 --- a/ui/src/components/sidebar/Sidebar.tsx +++ b/ui/src/components/sidebar/Sidebar.tsx @@ -113,7 +113,7 @@ export const Sidebar = () => { content == null && !pinned ? 'translate-x-full' : 'translate-x-0' } ${ pinned ? 'lg:border-l' : 'lg:shadow-separator' - } lg:w-[420px] lg:right-0 lg:top-0 lg:z-40`} + } lg:w-[380px] lg:right-0 lg:top-0 lg:z-40`} > {content}