π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
conv
Manav Rathi62a8b2dc8818
diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsxindex 119c4f7107..4b5d9f4b4f 100644--- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx+++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx@@ -23,7 +23,7 @@ import {import { AllAlbums } from "components/Collections/AllAlbums";import { SetCollectionNamerAttributes } from "components/Collections/CollectionNamer";import { CollectionShare } from "components/Collections/CollectionShare";-import { ITEM_TYPE, TimeStampListItem } from "components/FileList";+import { TimeStampListItem } from "components/FileList";import React, { useCallback, useEffect, useMemo, useState } from "react";import { sortCollectionSummaries } from "services/collectionService";import { SetFilesDownloadProgressAttributesCreator } from "types/gallery";@@ -167,7 +167,7 @@ export const GalleryBarAndListHeader: React.FC<CollectionsProps> = ({) : (<></>),- itemType: ITEM_TYPE.HEADER,+ tag: "header",height: 68,});}, [diff --git a/web/apps/photos/src/components/FileList.tsx b/web/apps/photos/src/components/FileList.tsxindex 48771df94d..ad794af2ce 100644--- a/web/apps/photos/src/components/FileList.tsx+++ b/web/apps/photos/src/components/FileList.tsx@@ -52,17 +52,14 @@ const FOOTER_HEIGHT = 90;const ALBUM_FOOTER_HEIGHT = 75;const ALBUM_FOOTER_HEIGHT_WITH_REFERRAL = 113;-export enum ITEM_TYPE {- TIME = "TIME",- FILE = "FILE",- HEADER = "HEADER",- FOOTER = "FOOTER",- MARKETING_FOOTER = "MARKETING_FOOTER",- OTHER = "OTHER",-}+export type FileListItemTag = "header" | "publicAlbumsFooter" | "date" | "file";export interface TimeStampListItem {- itemType: ITEM_TYPE;+ /**+ * An optional {@link FileListItemTag} that can be used to identify item+ * types for conditional behaviour.+ */+ tag?: FileListItemTag;items?: FileListAnnotatedFile[];itemStartIndex?: number;date?: string;@@ -256,10 +253,7 @@ export const FileList: React.FC<FileListProps> = ({useEffect(() => {setTimeStampList((timeStampList) => {timeStampList = timeStampList ?? [];- const hasHeader =- timeStampList.length > 0 &&- timeStampList[0].itemType === ITEM_TYPE.HEADER;-+ const hasHeader = timeStampList[0]?.tag == "header";if (hasHeader) {return timeStampList;}@@ -289,8 +283,8 @@ export const FileList: React.FC<FileListProps> = ({timeStampList = timeStampList ?? [];const hasFooter =timeStampList.length > 0 &&- timeStampList[timeStampList.length - 1].itemType ===- ITEM_TYPE.MARKETING_FOOTER;+ timeStampList[timeStampList.length - 1]?.tag ==+ "publicAlbumsFooter";if (hasFooter) {return timeStampList;}@@ -334,12 +328,12 @@ export const FileList: React.FC<FileListProps> = ({currentDate = item.file.metadata.creationTime / 1000;timeStampList.push({- itemType: ITEM_TYPE.TIME,+ tag: "date",date: item.timelineDateString,id: currentDate.toString(),});timeStampList.push({- itemType: ITEM_TYPE.FILE,+ tag: "file",items: [item],itemStartIndex: index,});@@ -350,7 +344,7 @@ export const FileList: React.FC<FileListProps> = ({} else {listItemIndex = 1;timeStampList.push({- itemType: ITEM_TYPE.FILE,+ tag: "file",items: [item],itemStartIndex: index,});@@ -367,7 +361,7 @@ export const FileList: React.FC<FileListProps> = ({} else {listItemIndex = 1;timeStampList.push({- itemType: ITEM_TYPE.FILE,+ tag: "file",items: [item],itemStartIndex: index,});@@ -399,7 +393,6 @@ export const FileList: React.FC<FileListProps> = ({const getEmptyListItem = () => {return {- itemType: ITEM_TYPE.OTHER,item: (<NothingContainer span={columns}><Typography sx={{ color: "text.faint" }}>@@ -433,7 +426,6 @@ export const FileList: React.FC<FileListProps> = ({return sum;})();return {- itemType: ITEM_TYPE.OTHER,item: <></>,height: Math.max(height - fileListHeight - footerHeight, 0),};@@ -441,7 +433,7 @@ export const FileList: React.FC<FileListProps> = ({const getAppDownloadFooter = () => {return {- itemType: ITEM_TYPE.MARKETING_FOOTER,+ tag: "publicAlbumsFooter",height: FOOTER_HEIGHT,item: (<FooterContainer span={columns}>@@ -473,7 +465,7 @@ export const FileList: React.FC<FileListProps> = ({const getAlbumsFooter = () => {return {- itemType: ITEM_TYPE.MARKETING_FOOTER,+ itemType: "publicAlbumsFooter",height: publicCollectionGalleryContext.referralCode? ALBUM_FOOTER_HEIGHT_WITH_REFERRAL: ALBUM_FOOTER_HEIGHT,@@ -546,7 +538,7 @@ export const FileList: React.FC<FileListProps> = ({const currItem = items[index];// If the current item is of type time, then it is not part of an ongoing date.// So, there is a possibility of merge.- if (currItem.itemType === ITEM_TYPE.TIME) {+ if (currItem.tag == "date") {// If new list pointer is not at the end of list then// we can add more items to the same list.if (newList[newIndex]) {@@ -601,7 +593,7 @@ export const FileList: React.FC<FileListProps> = ({for (let i = 0; i < newList.length; i++) {const currItem = newList[i];const nextItem = newList[i + 1];- if (currItem.itemType === ITEM_TYPE.TIME) {+ if (currItem.tag == "date") {if (currItem.dates.length > 1) {currItem.groups = currItem.dates.map((item) => item.span);nextItem.groups = currItem.groups;@@ -612,10 +604,10 @@ export const FileList: React.FC<FileListProps> = ({};const getItemSize = (timeStampList) => (index) => {- switch (timeStampList[index].itemType) {- case ITEM_TYPE.TIME:+ switch (timeStampList[index].tag) {+ case "date":return DATE_CONTAINER_HEIGHT;- case ITEM_TYPE.FILE:+ case "file":return listItemHeight;default:return timeStampList[index].height;@@ -623,8 +615,8 @@ export const FileList: React.FC<FileListProps> = ({};const generateKey = (index) => {- switch (timeStampList[index].itemType) {- case ITEM_TYPE.FILE:+ switch (timeStampList[index].tag) {+ case "file":return `${timeStampList[index].items[0].file.id}-${timeStampList[index].items.slice(-1)[0].file.id}`;@@ -798,8 +790,8 @@ export const FileList: React.FC<FileListProps> = ({// Enhancement: This logic doesn't work on the shared album screen, the// galleryContext.selectedFile is always null there.const haveSelection = (galleryContext.selectedFile?.count ?? 0) > 0;- switch (listItem.itemType) {- case ITEM_TYPE.TIME:+ switch (listItem.tag) {+ case "date":return listItem.dates ? (listItem.dates.map((item) => [@@ -842,7 +834,7 @@ export const FileList: React.FC<FileListProps> = ({{listItem.date}</DateContainer>);- case ITEM_TYPE.FILE: {+ case "file": {const ret = listItem.items.map((item, idx) =>getThumbnail(item,diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 783b4c3abb..0741bcaaba 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -94,7 +94,7 @@ import CollectionNamer, {} from "components/Collections/CollectionNamer";import { GalleryBarAndListHeader } from "components/Collections/GalleryBarAndListHeader";import { Export } from "components/Export";-import { ITEM_TYPE, TimeStampListItem } from "components/FileList";+import { TimeStampListItem } from "components/FileList";import { FileListWithViewer } from "components/FileListWithViewer";import {FilesDownloadProgress,@@ -428,7 +428,7 @@ const Page: React.FC = () => {fileCount={state.searchResults?.length ?? 0}/>),- itemType: ITEM_TYPE.HEADER,+ tag: "header",});}}, [isInSearchMode, state.searchSuggestion, state.searchResults]);diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsxindex 7def6ae0ea..aa73a2d322 100644--- a/web/apps/photos/src/pages/shared-albums.tsx+++ b/web/apps/photos/src/pages/shared-albums.tsx@@ -51,7 +51,7 @@ import DownloadIcon from "@mui/icons-material/Download";import FileDownloadOutlinedIcon from "@mui/icons-material/FileDownloadOutlined";import { Box, Button, IconButton, Stack, styled, Tooltip } from "@mui/material";import Typography from "@mui/material/Typography";-import { ITEM_TYPE, TimeStampListItem } from "components/FileList";+import { TimeStampListItem } from "components/FileList";import { FileListWithViewer } from "components/FileListWithViewer";import {FilesDownloadProgress,@@ -266,7 +266,7 @@ export default function PublicCollectionGallery() {}}/>),- itemType: ITEM_TYPE.HEADER,+ tag: "header",height: 68,});}, [publicCollection, publicFiles]);@@ -280,7 +280,6 @@ export default function PublicCollectionGallery() {<AddMorePhotosButton onClick={onAddPhotos} /></CenteredFlex>),- itemType: ITEM_TYPE.FOOTER,height: 104,}: null,