make shared-album collection info header scrollable

This commit is contained in:
Abhinav 2022-06-26 11:55:57 +05:30
parent 48e37e1160
commit 0097c99bcc
6 changed files with 46 additions and 17 deletions

View file

@ -69,7 +69,7 @@ export default function Collections(props: Iprops) {
} }
/> />
), ),
itemType: ITEM_TYPE.STATIC, itemType: ITEM_TYPE.OTHER,
height: 68, height: 68,
}), }),
[collectionSummaries, activeCollectionID, shouldBeHidden] [collectionSummaries, activeCollectionID, shouldBeHidden]

View file

@ -30,7 +30,7 @@ export enum ITEM_TYPE {
TIME = 'TIME', TIME = 'TIME',
FILE = 'FILE', FILE = 'FILE',
SIZE_AND_COUNT = 'SIZE_AND_COUNT', SIZE_AND_COUNT = 'SIZE_AND_COUNT',
STATIC = 'static', OTHER = 'OTHER',
} }
export interface TimeStampListItem { export interface TimeStampListItem {
@ -141,6 +141,7 @@ export function PhotoList({
resetFetching, resetFetching,
}: Props) { }: Props) {
const galleryContext = useContext(GalleryContext); const galleryContext = useContext(GalleryContext);
const timeStampListRef = useRef([]); const timeStampListRef = useRef([]);
const timeStampList = timeStampListRef?.current ?? []; const timeStampList = timeStampListRef?.current ?? [];
const filteredDataCopyRef = useRef([]); const filteredDataCopyRef = useRef([]);
@ -170,7 +171,15 @@ export function PhotoList({
let timeStampList: TimeStampListItem[] = []; let timeStampList: TimeStampListItem[] = [];
if (galleryContext.photoListHeader) { if (galleryContext.photoListHeader) {
timeStampList.push(getPhotoListHeader()); timeStampList.push(
getPhotoListHeader(galleryContext.photoListHeader)
);
} else if (publicCollectionGalleryContext.photoListHeader) {
timeStampList.push(
getPhotoListHeader(
publicCollectionGalleryContext.photoListHeader
)
);
} }
if (deduplicateContext.isOnDeduplicatePage) { if (deduplicateContext.isOnDeduplicatePage) {
skipMerge = true; skipMerge = true;
@ -303,12 +312,12 @@ export function PhotoList({
first.getMonth() === second.getMonth() && first.getMonth() === second.getMonth() &&
first.getDate() === second.getDate(); first.getDate() === second.getDate();
const getPhotoListHeader = () => { const getPhotoListHeader = (photoListHeader) => {
return { return {
...galleryContext.photoListHeader, ...photoListHeader,
item: ( item: (
<ListItemContainer span={columns}> <ListItemContainer span={columns}>
{galleryContext.photoListHeader.item} {photoListHeader.item}
</ListItemContainer> </ListItemContainer>
), ),
}; };
@ -316,7 +325,7 @@ export function PhotoList({
const getEmptyListItem = () => { const getEmptyListItem = () => {
return { return {
itemType: ITEM_TYPE.STATIC, itemType: ITEM_TYPE.OTHER,
item: ( item: (
<NothingContainer span={columns}> <NothingContainer span={columns}>
<div>{constants.NOTHING_HERE}</div> <div>{constants.NOTHING_HERE}</div>
@ -339,7 +348,7 @@ export function PhotoList({
return sum; return sum;
})(); })();
return { return {
itemType: ITEM_TYPE.STATIC, itemType: ITEM_TYPE.OTHER,
item: <></>, item: <></>,
height: Math.max(height - photoFrameHeight - FOOTER_HEIGHT, 0), height: Math.max(height - photoFrameHeight - FOOTER_HEIGHT, 0),
}; };
@ -347,7 +356,7 @@ export function PhotoList({
const getAppDownloadFooter = () => { const getAppDownloadFooter = () => {
return { return {
itemType: ITEM_TYPE.STATIC, itemType: ITEM_TYPE.OTHER,
height: FOOTER_HEIGHT, height: FOOTER_HEIGHT,
item: ( item: (
<FooterContainer span={columns}> <FooterContainer span={columns}>
@ -359,7 +368,7 @@ export function PhotoList({
const getAlbumsFooter = () => { const getAlbumsFooter = () => {
return { return {
itemType: ITEM_TYPE.STATIC, itemType: ITEM_TYPE.OTHER,
height: FOOTER_HEIGHT, height: FOOTER_HEIGHT,
item: ( item: (
<FooterContainer span={columns}> <FooterContainer span={columns}>

View file

@ -317,7 +317,7 @@ export default function Gallery() {
searchResultSummary={searchResultSummary} searchResultSummary={searchResultSummary}
/> />
), ),
itemType: ITEM_TYPE.STATIC, itemType: ITEM_TYPE.OTHER,
}); });
} }
}, [isInSearchMode, searchResultSummary]); }, [isInSearchMode, searchResultSummary]);

View file

@ -35,6 +35,7 @@ import { logError } from 'utils/sentry';
import SharedAlbumNavbar from 'components/pages/sharedAlbum/Navbar'; import SharedAlbumNavbar from 'components/pages/sharedAlbum/Navbar';
import { CollectionInfo } from 'components/Collections/CollectionInfo'; import { CollectionInfo } from 'components/Collections/CollectionInfo';
import { CollectionInfoBarWrapper } from 'components/Collections/styledComponents'; import { CollectionInfoBarWrapper } from 'components/Collections/styledComponents';
import { ITEM_TYPE, TimeStampListItem } from 'components/PhotoList';
const Loader = () => ( const Loader = () => (
<VerticallyCentered> <VerticallyCentered>
@ -61,6 +62,8 @@ export default function PublicCollectionGallery() {
const router = useRouter(); const router = useRouter();
const [isPasswordProtected, setIsPasswordProtected] = const [isPasswordProtected, setIsPasswordProtected] =
useState<boolean>(false); useState<boolean>(false);
const [photoListHeader, setPhotoListHeader] =
useState<TimeStampListItem>(null);
useEffect(() => { useEffect(() => {
const currentURL = new URL(window.location.href); const currentURL = new URL(window.location.href);
@ -120,6 +123,25 @@ export default function PublicCollectionGallery() {
main(); main();
}, []); }, []);
useEffect(
() =>
publicCollection &&
publicFiles &&
setPhotoListHeader({
item: (
<CollectionInfoBarWrapper>
<CollectionInfo
name={publicCollection.name}
fileCount={publicFiles.length}
/>
</CollectionInfoBarWrapper>
),
itemType: ITEM_TYPE.OTHER,
height: 68,
}),
[publicCollection, publicFiles]
);
const syncWithRemote = async () => { const syncWithRemote = async () => {
const collectionUID = getPublicCollectionUID(token.current); const collectionUID = getPublicCollectionUID(token.current);
try { try {
@ -278,14 +300,9 @@ export default function PublicCollectionGallery() {
passwordToken: passwordJWTToken.current, passwordToken: passwordJWTToken.current,
accessedThroughSharedURL: true, accessedThroughSharedURL: true,
openReportForm, openReportForm,
photoListHeader,
}}> }}>
<SharedAlbumNavbar /> <SharedAlbumNavbar />
<CollectionInfoBarWrapper>
<CollectionInfo
name={publicCollection.name}
fileCount={publicFiles.length}
/>
</CollectionInfoBarWrapper>
<PhotoFrame <PhotoFrame
files={publicFiles} files={publicFiles}
setFiles={setPublicFiles} setFiles={setPublicFiles}

View file

@ -1,3 +1,4 @@
import { TimeStampListItem } from 'components/PhotoList';
import { REPORT_REASON } from 'constants/publicCollection'; import { REPORT_REASON } from 'constants/publicCollection';
import { EnteFile } from 'types/file'; import { EnteFile } from 'types/file';
@ -6,6 +7,7 @@ export interface PublicCollectionGalleryContextType {
passwordToken: string; passwordToken: string;
accessedThroughSharedURL: boolean; accessedThroughSharedURL: boolean;
openReportForm: () => void; openReportForm: () => void;
photoListHeader: TimeStampListItem;
} }
export interface LocalSavedPublicCollectionFiles { export interface LocalSavedPublicCollectionFiles {

View file

@ -7,6 +7,7 @@ export const defaultPublicCollectionGalleryContext: PublicCollectionGalleryConte
passwordToken: null, passwordToken: null,
accessedThroughSharedURL: false, accessedThroughSharedURL: false,
openReportForm: () => null, openReportForm: () => null,
photoListHeader: null,
}; };
export const PublicCollectionGalleryContext = export const PublicCollectionGalleryContext =