π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Update more
Manav Rathiae28125a7aed
diff --git a/web/apps/photos/eslint.config.mjs b/web/apps/photos/eslint.config.mjsindex 3da791ba73..c4e97c3d6a 100644--- a/web/apps/photos/eslint.config.mjs+++ b/web/apps/photos/eslint.config.mjs@@ -9,7 +9,6 @@ export default [* "This rule requires the `strictNullChecks` compiler option to be* turned on to function correctly"*/- "@typescript-eslint/no-unnecessary-condition": "off",/** TODO: Disabled as we migrate, try to prune these again */"react-hooks/exhaustive-deps": "off",},diff --git a/web/apps/photos/src/components/Collections/AllAlbums.tsx b/web/apps/photos/src/components/Collections/AllAlbums.tsxindex f7d54286ca..aeb1797e35 100644--- a/web/apps/photos/src/components/Collections/AllAlbums.tsx+++ b/web/apps/photos/src/components/Collections/AllAlbums.tsx@@ -1,3 +1,4 @@+// TODO: Audit this file.import CloseIcon from "@mui/icons-material/Close";import {Box,@@ -225,9 +226,6 @@ const AllAlbumsContent: React.FC<AllAlbumsContentProps> = ({32; /* padding above first and below last row */useEffect(() => {- if (!collectionSummaries) {- return;- }const main = () => {if (refreshInProgress.current) {shouldRefresh.current = true;diff --git a/web/apps/photos/src/components/Collections/CollectionHeader.tsx b/web/apps/photos/src/components/Collections/CollectionHeader.tsxindex 91790a6a97..8ed21cdab9 100644--- a/web/apps/photos/src/components/Collections/CollectionHeader.tsx+++ b/web/apps/photos/src/components/Collections/CollectionHeader.tsx@@ -15,7 +15,6 @@ import UnarchiveIcon from "@mui/icons-material/Unarchive";import VisibilityOffOutlinedIcon from "@mui/icons-material/VisibilityOffOutlined";import VisibilityOutlinedIcon from "@mui/icons-material/VisibilityOutlined";import { Box, IconButton, Menu, Stack, Tooltip } from "@mui/material";-import { assertionFailed } from "ente-base/assert";import { SpacedRow } from "ente-base/components/containers";import { ActivityIndicator } from "ente-base/components/mui/ActivityIndicator";import {@@ -63,6 +62,7 @@ import { Trans } from "react-i18next";export interface CollectionHeaderProps {collectionSummary: CollectionSummary;+ // TODO: This can be undefinedactiveCollection: Collection;setActiveCollectionID: (collectionID: number) => void;isActiveCollectionDownloadInProgress: () => boolean;@@ -86,10 +86,6 @@ export interface CollectionHeaderProps {*/export const CollectionHeader: React.FC<CollectionHeaderProps> = (props) => {const { collectionSummary } = props;- if (!collectionSummary) {- assertionFailed("Gallery/CollectionHeader without a collection");- return <></>;- }const { name, type, attributes, fileCount } = collectionSummary;@@ -548,6 +544,8 @@ const CollectionHeaderOptions: React.FC<CollectionHeaderProps> = ({{...albumNameInputVisibilityProps}title={t("rename_album")}label={t("album_name")}+ // TODO: Need to ensure this cannot be undefined when we reach here+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-conditioninitialValue={activeCollection?.name}submitButtonColor="primary"submitButtonTitle={t("rename")}@@ -735,7 +733,7 @@ const CollectionSortOrderMenu: React.FC<CollectionSortOrderMenuProps> = ({return (<Menuid="collection-files-sort"- anchorEl={overflowMenuIconRef?.current}+ anchorEl={overflowMenuIconRef.current}open={open}onClose={onClose}slotProps={{diff --git a/web/apps/photos/src/components/Collections/CollectionShare.tsx b/web/apps/photos/src/components/Collections/CollectionShare.tsxindex 8e3a05ae8c..9679f04c04 100644--- a/web/apps/photos/src/components/Collections/CollectionShare.tsx+++ b/web/apps/photos/src/components/Collections/CollectionShare.tsx@@ -1,3 +1,5 @@+// TODO: Audit this file+/* eslint-disable @typescript-eslint/no-unnecessary-condition */import AddIcon from "@mui/icons-material/Add";import AdminPanelSettingsIcon from "@mui/icons-material/AdminPanelSettings";import BlockIcon from "@mui/icons-material/Block";diff --git a/web/apps/photos/src/components/DownloadStatusNotifications.tsx b/web/apps/photos/src/components/DownloadStatusNotifications.tsxindex 40d8f7a28d..2546a43aa6 100644--- a/web/apps/photos/src/components/DownloadStatusNotifications.tsx+++ b/web/apps/photos/src/components/DownloadStatusNotifications.tsx@@ -57,7 +57,7 @@ export const DownloadStatusNotifications: React.FC<text: t("yes_stop_downloads"),color: "critical",action: () => {- group?.canceller.abort();+ group.canceller.abort();onRemoveSaveGroup(group);},},@@ -86,10 +86,6 @@ export const DownloadStatusNotifications: React.FC<}};- if (!saveGroups) {- return <></>;- }-return saveGroups.map((group, index) => (<Notificationkey={group.id}diff --git a/web/apps/photos/src/components/FileList.tsx b/web/apps/photos/src/components/FileList.tsxindex f8071fd598..9bc755283f 100644--- a/web/apps/photos/src/components/FileList.tsx+++ b/web/apps/photos/src/components/FileList.tsx@@ -41,7 +41,7 @@ import {VariableSizeList,areEqual,} from "react-window";-import { type SelectedState, shouldShowAvatar } from "utils/file";+import { type SelectedState } from "utils/file";import {handleSelectCreator,handleSelectCreatorMulti,@@ -483,10 +483,7 @@ export const FileList: React.FC<FileListProps> = ({};useEffect(() => {- // Nothing to do here if nothing is selected.- if (!selected) return;-- const notSelectedFiles = (annotatedFiles ?? []).filter(+ const notSelectedFiles = annotatedFiles.filter((item) => !selected[item.file.id],);@@ -494,7 +491,7 @@ export const FileList: React.FC<FileListProps> = ({notSelectedFiles.map((item) => item.timelineDateString),); // to get file's date which were manually unselected- const localSelectedFiles = (annotatedFiles ?? []).filter(+ const localSelectedFiles = annotatedFiles.filter(// to get files which were manually selected(item) => !unselectedDates.has(item.timelineDateString),);@@ -535,7 +532,7 @@ export const FileList: React.FC<FileListProps> = ({}setCheckedTimelineDateStrings(next);- const filesOnADay = annotatedFiles?.filter(+ const filesOnADay = annotatedFiles.filter((item) => item.timelineDateString === date,); // all files on a checked/unchecked day@@ -649,7 +646,7 @@ export const FileList: React.FC<FileListProps> = ({listItem: TimeStampListItem,isScrolling: boolean | undefined,) => {- const haveSelection = (selected.count ?? 0) > 0;+ const haveSelection = selected.count > 0;switch (listItem.tag) {case "date":return listItem.dates ? (@@ -725,7 +722,7 @@ export const FileList: React.FC<FileListProps> = ({}};- if (!timeStampList?.length) {+ if (!timeStampList.length) {return <></>;}@@ -1007,13 +1004,13 @@ const FileThumbnail: React.FC<FileThumbnailProps> = ({onSelect(!selected);}} else if (imageURL) {- onClick?.();+ onClick();}};const handleSelect: React.ChangeEventHandler<HTMLInputElement> = (e) => {if (isRangeSelectActive) {- onRangeSelect?.();+ onRangeSelect();} else {onSelect(e.target.checked);}@@ -1270,3 +1267,19 @@ const VideoDurationOverlay: React.FC<VideoDurationOverlayProps> = ({)}</FileTypeIndicatorOverlay>);++/**+ * Return `true` if the owner or uploader name avatar indicator should be shown+ * for the given {@link file}.+ */+const shouldShowAvatar = (file: EnteFile, user: LocalUser | undefined) => {+ // Public albums app.+ if (!user) return false;+ // A file shared with the user.+ if (file.ownerID != user.id) return true;+ // A public collected file (i.e. a file owned by the user, uploaded by an+ // named guest via a public collect link)+ if (file.pubMagicMetadata?.data.uploaderName) return true;+ // Regular file.+ return false;+};diff --git a/web/apps/photos/src/components/FileListWithViewer.tsx b/web/apps/photos/src/components/FileListWithViewer.tsxindex 13ebc7c5c9..df253a1a62 100644--- a/web/apps/photos/src/components/FileListWithViewer.tsx+++ b/web/apps/photos/src/components/FileListWithViewer.tsx@@ -159,7 +159,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({const handleDelete = useMemo(() => {return onMarkTempDeleted? (file: EnteFile) =>- moveToTrash([file]).then(() => onMarkTempDeleted?.([file]))+ moveToTrash([file]).then(() => onMarkTempDeleted([file])): undefined;}, [onMarkTempDeleted]);diff --git a/web/apps/photos/src/components/Sidebar.tsx b/web/apps/photos/src/components/Sidebar.tsxindex 308334a4ac..ed2ee646e4 100644--- a/web/apps/photos/src/components/Sidebar.tsx+++ b/web/apps/photos/src/components/Sidebar.tsx@@ -364,7 +364,7 @@ const SubscriptionStatus: React.FC<SubscriptionStatusProps> = ({message = t("subscription_info_free");} else if (isSubscriptionCancelled(userDetails.subscription)) {message = t("subscription_info_renewal_cancelled", {- date: userDetails.subscription?.expiryTime,+ date: userDetails.subscription.expiryTime,});}} else {diff --git a/web/apps/photos/src/components/SubscriptionCard.tsx b/web/apps/photos/src/components/SubscriptionCard.tsxindex abf26b8190..f695207da4 100644--- a/web/apps/photos/src/components/SubscriptionCard.tsx+++ b/web/apps/photos/src/components/SubscriptionCard.tsx@@ -233,7 +233,7 @@ const IndividualUsageSection: React.FC<IndividualUsageSectionProps> = ({{`${formattedStorageByteSize(storage - usage)} ${t("free")}`}</Typography><Typography variant="mini" sx={{ fontWeight: "medium" }}>- {t("photos_count", { count: fileCount ?? 0 })}+ {t("photos_count", { count: fileCount })}</Typography></Stack></Stack>@@ -326,7 +326,7 @@ const FamilyUsageSection: React.FC<FamilyUsageSectionProps> = ({<Legend label={t("family")} opacity={0.8} /></Stack><Typography variant="mini" sx={{ fontWeight: "medium" }}>- {t("photos_count", { count: fileCount ?? 0 })}+ {t("photos_count", { count: fileCount })}</Typography></Stack></Stack>diff --git a/web/apps/photos/src/components/Upload.tsx b/web/apps/photos/src/components/Upload.tsxindex 30b31cc8d3..1626d770df 100644--- a/web/apps/photos/src/components/Upload.tsx+++ b/web/apps/photos/src/components/Upload.tsx@@ -188,9 +188,9 @@ export const Upload: React.FC<UploadProps> = ({finished: 0,total: 0,});- const [inProgressUploads, setInProgressUploads] = useState<- InProgressUpload[]- >([]);+ const [inProgressUploads, setInProgressUploads] = useState(+ new Array<InProgressUpload>(),+ );const [finishedUploads, setFinishedUploads] =useState<SegregatedFinishedUploads>(new Map());const [percentComplete, setPercentComplete] = useState(0);@@ -853,7 +853,7 @@ export const Upload: React.FC<UploadProps> = ({const handleCollectionMappingSelect = (mapping: CollectionMapping) =>uploadFilesToNewCollections(mapping,- importSuggestion.rootFolderName ??+ importSuggestion.rootFolderName ||t("autogenerated_default_album_name"),);@@ -1152,15 +1152,10 @@ const UploadTypeSelector: React.FC<UploadTypeSelectorProps> = ({}}, [open, publicAlbumsCredentials]);- const handleClose: DialogProps["onClose"] = (_, reason) => {+ const handleClose: DialogProps["onClose"] = () => {// Disable backdrop clicks and esc keypresses if a selection is pending// processing so that the user doesn't inadvertently close the dialog.- if (- pendingUploadType &&- (reason == "backdropClick" || reason == "escapeKeyDown")- ) {- return;- }+ if (pendingUploadType) return;onClose();};diff --git a/web/apps/photos/src/components/UploadProgress.tsx b/web/apps/photos/src/components/UploadProgress.tsxindex d2a2aec71b..f5366faeeb 100644--- a/web/apps/photos/src/components/UploadProgress.tsx+++ b/web/apps/photos/src/components/UploadProgress.tsx@@ -380,7 +380,7 @@ const InProgressSection: React.FC = () => {const { inProgressUploads, hasLivePhotos, uploadFileNames, uploadPhase } =useUploadProgressContext();- const fileList = inProgressUploads ?? [];+ const fileList = inProgressUploads;// @ts-expect-error Need to add typesconst renderListItem = ({ localFileID, progress }) => {@@ -414,7 +414,7 @@ const InProgressSection: React.FC = () => {<SectionAccordionSummary expandIcon={<ExpandMoreIcon />}><TitleTexttitle={t("uploads_in_progress")}- count={inProgressUploads?.length}+ count={inProgressUploads.length}/></SectionAccordionSummary><SectionAccordionDetails>@@ -530,7 +530,7 @@ const ResultSection: React.FC<ResultSectionProps> = ({return (<SectionAccordion><SectionAccordionSummary expandIcon={<ExpandMoreIcon />}>- <TitleText title={sectionTitle} count={fileList?.length} />+ <TitleText title={sectionTitle} count={fileList.length} /></SectionAccordionSummary><SectionAccordionDetails>{sectionInfo && <SectionInfo>{sectionInfo}</SectionInfo>}diff --git a/web/apps/photos/src/pages/_app.tsx b/web/apps/photos/src/pages/_app.tsxindex 9310e89365..ae009c7ec8 100644--- a/web/apps/photos/src/pages/_app.tsx+++ b/web/apps/photos/src/pages/_app.tsx@@ -141,7 +141,7 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {}router.events.on("routeChangeStart", (url: string, o: NROptions) => {if (process.env.NEXT_PUBLIC_ENTE_TRACE_RT) {- log.debug(() => [o?.shallow ? "route-shallow" : "route", url]);+ log.debug(() => [o.shallow ? "route-shallow" : "route", url]);}if (needsFamilyRedirect && savedPartialLocalUser()?.token) {diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex b471f67846..81b8bd509e 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -452,7 +452,7 @@ const Page: React.FC = () => {// - We haven't fetched the user yet;!user ||// - There is nothing to select;- !filteredFiles?.length ||+ !filteredFiles.length ||// - Any of the modals are open.uploadTypeSelectorView ||openCollectionSelector ||@@ -493,7 +493,7 @@ const Page: React.FC = () => {};const clearSelection = () => {- if (!selected?.count) {+ if (!selected.count) {return;}setSelected({@@ -1094,7 +1094,7 @@ const Page: React.FC = () => {emailByUserID={state.emailByUserID}shareSuggestionEmails={state.shareSuggestionEmails}people={- (state?.view?.type == "people"+ (state.view?.type == "people"? state.view.visiblePeople: undefined) ?? []}@@ -1152,7 +1152,7 @@ const Page: React.FC = () => {/>) : !isInSearchMode &&!isFirstLoad &&- state?.view?.type == "people" &&+ state.view?.type == "people" &&!state.view.activePerson ? (<PeopleEmptyState />) : (@@ -1338,7 +1338,7 @@ const handleSubscriptionCompletionRedirectIfNeeded = async (message: (<Transi18nKey="subscription_purchase_success"- values={{ date: subscription?.expiryTime }}+ values={{ date: subscription.expiryTime }}/>),continue: { text: t("ok") },diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsxindex cd6b842e7f..911d48e312 100644--- a/web/apps/photos/src/pages/shared-albums.tsx+++ b/web/apps/photos/src/pages/shared-albums.tsx@@ -216,7 +216,7 @@ export default function PublicCollectionGallery() {}, []);const downloadEnabled =- publicCollection?.publicURLs?.[0]?.enableDownload ?? true;+ publicCollection?.publicURLs[0]?.enableDownload ?? true;/*** Pull the latest data related to the public album from remote, updating@@ -351,7 +351,7 @@ export default function PublicCollectionGallery() {};const clearSelection = () => {- if (!selected?.count) {+ if (!selected.count) {return;}setSelected({@@ -400,6 +400,7 @@ export default function PublicCollectionGallery() {{...{publicCollection,publicFiles,+ downloadEnabled,onAddSaveGroup,}}/>@@ -407,7 +408,7 @@ export default function PublicCollectionGallery() {height: fileListHeaderHeight,}: undefined,- [onAddSaveGroup, publicCollection, publicFiles],+ [onAddSaveGroup, publicCollection, publicFiles, downloadEnabled],);const fileListFooter = useMemo(() => {@@ -621,6 +622,7 @@ const SelectedFileOptions: React.FC<SelectedFileOptionsProps> = ({interface FileListHeaderProps {publicCollection: Collection;publicFiles: EnteFile[];+ downloadEnabled: boolean;onAddSaveGroup: AddSaveGroup;}@@ -638,11 +640,9 @@ const fileListHeaderHeight = 68;const FileListHeader: React.FC<FileListHeaderProps> = ({publicCollection,publicFiles,+ downloadEnabled,onAddSaveGroup,}) => {- const downloadEnabled =- publicCollection.publicURLs?.[0]?.enableDownload ?? true;-const downloadAllFiles = () =>downloadAndSaveCollectionFiles(publicCollection.name,diff --git a/web/apps/photos/src/services/upload-manager.ts b/web/apps/photos/src/services/upload-manager.tsindex 34680f1873..b8ef90991b 100644--- a/web/apps/photos/src/services/upload-manager.ts+++ b/web/apps/photos/src/services/upload-manager.ts@@ -1,3 +1,4 @@+// TODO: Audit this file// TODO: Too many null assertions in this file. The types need reworking.import { ensureLocalUser } from "ente-accounts/services/user";import { isDesktop } from "ente-base/app";@@ -204,15 +205,14 @@ class UIService {let percentComplete =this.perFileProgress *(this.finishedUploads.size || this.filesUploadedCount);- if (this.inProgressUploads) {- // eslint-disable-next-line @typescript-eslint/no-unused-vars- for (const [_, progress] of this.inProgressUploads) {- // filter negative indicator values during percentComplete calculation- if (progress < 0) {- continue;- }- percentComplete += (this.perFileProgress * progress) / 100;++ // eslint-disable-next-line @typescript-eslint/no-unused-vars+ for (const [_, progress] of this.inProgressUploads) {+ // filter negative indicator values during percentComplete calculation+ if (progress < 0) {+ continue;}+ percentComplete += (this.perFileProgress * progress) / 100;}setPercentComplete(percentComplete);diff --git a/web/apps/photos/src/services/watch.ts b/web/apps/photos/src/services/watch.tsindex f2fec3a5dd..45a66c9bbf 100644--- a/web/apps/photos/src/services/watch.ts+++ b/web/apps/photos/src/services/watch.ts@@ -172,7 +172,6 @@ class FolderWatcher {private async syncWithDisk() {try {const watches = await this.getWatches();- if (!watches) return;this.eventQueue = [];const events = await deduceEvents(watches);diff --git a/web/apps/photos/src/utils/file/index.ts b/web/apps/photos/src/utils/file/index.tsindex 326cfc7ad1..6482c3dd63 100644--- a/web/apps/photos/src/utils/file/index.ts+++ b/web/apps/photos/src/utils/file/index.ts@@ -1,4 +1,3 @@-import type { LocalUser } from "ente-accounts/services/user";import type { AddSaveGroup } from "ente-gallery/components/utils/save-groups";import { downloadAndSaveFiles } from "ente-gallery/services/save";import type { EnteFile } from "ente-media/file";@@ -44,28 +43,6 @@ export function getSelectedFiles(return files.filter((file) => selectedFilesIDs.has(file.id));}-export const shouldShowAvatar = (- file: EnteFile,- user: LocalUser | undefined,-) => {- if (!file || !user) {- return false;- }- // is Shared file- else if (file.ownerID !== user.id) {- return true;- }- // is public collected file- else if (- file.ownerID === user.id &&- file.pubMagicMetadata?.data?.uploaderName- ) {- return true;- } else {- return false;- }-};-export const performFileOp = async (op: FileOp,files: EnteFile[],diff --git a/web/apps/photos/src/utils/photoFrame/index.ts b/web/apps/photos/src/utils/photoFrame/index.tsindex 96ed15fa6c..5680bd0309 100644--- a/web/apps/photos/src/utils/photoFrame/index.ts+++ b/web/apps/photos/src/utils/photoFrame/index.ts@@ -155,7 +155,7 @@ const createSelectedAndContext = (: { mode, collectionID: activeCollectionID },};} else {- if (selected.context?.mode == "people") {+ if (selected.context.mode == "people") {if (selected.context.personID != activePersonID) {// Clear selection if person has changed.selected = {@@ -163,7 +163,7 @@ const createSelectedAndContext = (count: 0,collectionID: 0,context: {- mode: selected.context?.mode,+ mode: selected.context.mode,personID: activePersonID!,},};@@ -176,7 +176,7 @@ const createSelectedAndContext = (count: 0,collectionID: 0,context: {- mode: selected.context?.mode,+ mode: selected.context.mode,collectionID: activeCollectionID,},};diff --git a/web/packages/new/photos/services/export.ts b/web/packages/new/photos/services/export.tsindex 33d24d9779..4654866fdb 100644--- a/web/packages/new/photos/services/export.ts+++ b/web/packages/new/photos/services/export.ts@@ -172,7 +172,7 @@ interface CancellationStatus {class ExportService {private exportSettings: ExportSettings | undefined;// @ts-ignore- private exportInProgress: RequestCanceller = null;+ private exportInProgress: RequestCanceller | null = null;private resync = true;private reRunNeeded = false;private exportRecordUpdater = new PromiseQueue<ExportRecord>();@@ -336,7 +336,7 @@ class ExportService {async stopRunningExport() {try {log.info("user requested export cancellation");- this.exportInProgress.exec();+ this.exportInProgress?.exec();// @ts-ignorethis.exportInProgress = null;this.reRunNeeded = false;