π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Remove unused public albums avatar
Anand Baburajan10d14a97aaa2
diff --git a/web/apps/albums/vendor/photos/components/Avatar.tsx b/web/apps/albums/vendor/photos/components/Avatar.tsxdeleted file mode 100644index 05feac15bf..0000000000--- a/web/apps/albums/vendor/photos/components/Avatar.tsx+++ /dev/null@@ -1,117 +0,0 @@-// TODO: Audit this file-/* eslint-disable react-hooks/exhaustive-deps */-import { styled } from "@mui/material";-import type { LocalUser } from "ente-accounts/services/user";-import log from "ente-base/log";-import { type EnteFile } from "ente-media/file";-import {- avatarBackgroundColor,- avatarBackgroundColorPublicCollectedFile,- avatarTextColor,-} from "ente-new/photos/services/avatar";-import React, { useLayoutEffect, useState } from "react";--interface AvatarProps {- user?: LocalUser;- file?: EnteFile;- email?: string;- opacity?: number;- emailByUserID?: Map<number, string>;-}--const AvatarBase = styled("div")<{- colorCode: string;- size: number;- opacity: number | undefined;-}>`- width: ${({ size }) => `${size}px`};- height: ${({ size }) => `${size}px`};- background-color: ${({ colorCode, opacity }) =>- `${colorCode}${opacity === 100 ? "" : (opacity ?? 95)}`};- border-radius: 50%;- display: flex;- justify-content: center;- align-items: center;- color: ${avatarTextColor};- font-weight: bold;- font-size: ${({ size }) => `${Math.floor(size / 2)}px`};-`;--const Avatar: React.FC<AvatarProps> = ({- user,- file,- email,- opacity,- emailByUserID,-}) => {- const [colorCode, setColorCode] = useState("");- const [userLetter, setUserLetter] = useState<string | undefined>("");-- useLayoutEffect(() => {- try {- if (!file) {- return;- }- if (file.ownerID !== user?.id) {- // getting email from in-memory id-email map- const email = emailByUserID?.get(file.ownerID);- if (!email) {- log.error("email not found in userIDToEmailMap");- return;- }- setUserLetter(email[0]?.toUpperCase());- setColorCode(avatarBackgroundColor(file.ownerID));- } else if (file.ownerID === user.id) {- const uploaderName = file.pubMagicMetadata?.data.uploaderName;- if (!uploaderName) {- log.error(- "uploaderName not found in file.pubMagicMetadata.data",- );- return;- }- setUserLetter(uploaderName[0]?.toUpperCase());- setColorCode(avatarBackgroundColorPublicCollectedFile);- }- } catch (e) {- log.error("AvatarIcon.tsx - useLayoutEffect file failed", e);- }- }, [file]);-- useLayoutEffect(() => {- try {- if (!email) {- return;- }-- if (user?.email === email) {- setUserLetter(email[0]?.toUpperCase());- setColorCode(avatarBackgroundColorPublicCollectedFile);- return;- }-- const id = Array.from(emailByUserID?.keys() ?? []).find(- (key) => emailByUserID?.get(key) === email,- );- if (!id) {- log.error(`ID not found for email: ${email}`);- return;- }- setUserLetter(email[0]?.toUpperCase());- setColorCode(avatarBackgroundColor(id));- } catch (e) {- log.error("AvatarIcon.tsx - useLayoutEffect email failed", e);- }- }, [user, email, emailByUserID]);-- if (!colorCode || !userLetter) {- return <></>;- }-- return (- <AvatarBase size={18} colorCode={colorCode} opacity={opacity}>- {userLetter}- </AvatarBase>- );-};--export default Avatar;diff --git a/web/apps/albums/vendor/photos/components/FileList.tsx b/web/apps/albums/vendor/photos/components/FileList.tsxindex 9819a6acd8..a998ca83fa 100644--- a/web/apps/albums/vendor/photos/components/FileList.tsx+++ b/web/apps/albums/vendor/photos/components/FileList.tsx@@ -3,7 +3,6 @@ import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp";import PlayArrowRoundedIcon from "@mui/icons-material/PlayArrowRounded";import PlayCircleOutlineOutlinedIcon from "@mui/icons-material/PlayCircleOutlineOutlined";import { Box, Checkbox, Fab, Typography, styled } from "@mui/material";-import Avatar from "components/Avatar";import type { LocalUser } from "ente-accounts/services/user";import { assertionFailed } from "ente-base/assert";import { Overlay } from "ente-base/components/containers";@@ -343,7 +342,6 @@ export const FileList: React.FC<FileListProps> = ({activeCollectionID,activePersonID,favoriteFileIDs,- emailByUserID,onItemClick,onScroll,onVisibleDateChange,@@ -898,8 +896,6 @@ export const FileList: React.FC<FileListProps> = ({<FileThumbnailkey={`tile-${file.id}-selected-${selected[file.id] ?? false}`}{...{- user,- emailByUserID,enableSelect:!!enableSelect &&!suppressSelectionUI,@@ -952,7 +948,6 @@ export const FileList: React.FC<FileListProps> = ({activeCollectionID,checkedTimelineDateStrings,contextMenu,- emailByUserID,favoriteFileIDs,haveSelection,handleContextMenu,@@ -1284,8 +1279,6 @@ export const FileList: React.FC<FileListProps> = ({<FileThumbnailkey={`tile-${file.id}-selected-${selected[file.id] ?? false}`}{...{- user,- emailByUserID,enableSelect:!!enableSelect && !suppressSelectionUI,}}@@ -1321,7 +1314,6 @@ export const FileList: React.FC<FileListProps> = ({},[activeCollectionID,- emailByUserID,enableSelect,favoriteFileIDs,handleContextMenu,@@ -1750,18 +1742,16 @@ type FileThumbnailProps = {onImageDimensions?: (dimensions: Dimensions) => void;isMasonry?: boolean;style?: React.CSSProperties;-} & Pick<FileListProps, "user" | "emailByUserID" | "enableSelect">;+} & Pick<FileListProps, "enableSelect">;const FileThumbnail: React.FC<FileThumbnailProps> = ({file,- user,enableSelect,selected,selectOnClick,isRangeSelectActive,isInSelectRange,isFav,- emailByUserID,activeCollectionID,showPlaceholder,onClick,@@ -1891,11 +1881,6 @@ const FileThumbnail: React.FC<FileThumbnailProps> = ({))}{selected && <SelectedOverlay />}- {shouldShowAvatar(file, user) && (- <AvatarOverlay>- <Avatar {...{ user, file, emailByUserID }} />- </AvatarOverlay>- )}{isFav && (<FavoriteOverlay><StarIcon fontSize="small" />@@ -2049,17 +2034,6 @@ const HoverOverlay = styled("div")<{ checked: boolean }>`"background:linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0))"};`;-/**- * An overlay showing the avatars of the person who shared the item, at the top- * right.- */-const AvatarOverlay = styled(Overlay)`- display: flex;- justify-content: flex-end;- align-items: flex-start;- padding: 5px;-`;-/*** An overlay showing the favorite icon at bottom left.*/@@ -2125,19 +2099,3 @@ 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;-};