π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
add fav button
Apalepexe0de52b915c3
diff --git a/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsx b/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsxindex 01d1cf7e87..ce84d37824 100644--- a/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsx+++ b/web/apps/photos/src/components/pages/gallery/SelectedFileOptions.tsx@@ -15,6 +15,7 @@ import RestoreIcon from "@mui/icons-material/Restore";import UnArchiveIcon from "@mui/icons-material/Unarchive";import VisibilityOffOutlined from "@mui/icons-material/VisibilityOffOutlined";import VisibilityOutlined from "@mui/icons-material/VisibilityOutlined";+import FavoriteBorderIcon from "@mui/icons-material/FavoriteBorderRounded";import { Box, IconButton, Stack, Tooltip } from "@mui/material";import { t } from "i18next";import { AppContext } from "pages/_app";@@ -28,6 +29,7 @@ import {import { FILE_OPS_TYPE } from "utils/file";import { formatNumber } from "utils/number/format";import { getTrashFilesMessage } from "utils/ui";+import Favorite from "@mui/icons-material/FavoriteRounded";interface Props {handleCollectionOps: (@@ -332,6 +334,15 @@ const SelectedFileOptions = ({<ClockIcon /></IconButton></Tooltip>+ {!isFavoriteCollection && (+ <Tooltip title={t("favorites")}>+ <IconButton+ onClick={handleFileOps(FILE_OPS_TYPE.SET_FAVORITE)}+ >+ <FavoriteBorderIcon />+ </IconButton>+ </Tooltip>+ )}<Tooltip title={t("download")}><IconButtononClick={handleFileOps(FILE_OPS_TYPE.DOWNLOAD)}diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 457f35a805..df6b3520c1 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -992,6 +992,7 @@ export default function Gallery() {setTempHiddenFileIds,setFixCreationTimeAttributes,setFilesDownloadProgressAttributesCreator,+ updateFavItemIds,);}clearSelection();@@ -1119,6 +1120,11 @@ export default function Gallery() {[],);+ const updateFavItemIds = async (ids: Set<Number>) => {+ const favItemIds = await getFavItemIds(files);+ setFavItemIds(favItemIds);+ };+if (!collectionSummaries || !filteredData) {return <div></div>;}diff --git a/web/apps/photos/src/services/collectionService.ts b/web/apps/photos/src/services/collectionService.tsindex d89801435e..289d8be917 100644--- a/web/apps/photos/src/services/collectionService.ts+++ b/web/apps/photos/src/services/collectionService.ts@@ -486,12 +486,16 @@ export const createFavoritesCollection = () => {};export const addToFavorites = async (file: EnteFile) => {+ await addMultipleToFavorites([file]);+}++export const addMultipleToFavorites = async (files: EnteFile[]) => {try {let favCollection = await getFavCollection();if (!favCollection) {favCollection = await createFavoritesCollection();}- await addToCollection(favCollection, [file]);+ await addToCollection(favCollection, files);} catch (e) {log.error("failed to add to favorite", e);}diff --git a/web/apps/photos/src/utils/file/index.ts b/web/apps/photos/src/utils/file/index.tsindex 19ebcf4c75..71f39954c1 100644--- a/web/apps/photos/src/utils/file/index.ts+++ b/web/apps/photos/src/utils/file/index.ts@@ -24,7 +24,7 @@ import { LS_KEYS, getData } from "@ente/shared/storage/localStorage";import type { User } from "@ente/shared/user/types";import { downloadUsingAnchor } from "@ente/shared/utils";import { t } from "i18next";-import { moveToHiddenCollection } from "services/collectionService";+import { addMultipleToFavorites, addToFavorites, moveToHiddenCollection } from "services/collectionService";import {deleteFromTrash,trashFiles,@@ -46,6 +46,7 @@ export enum FILE_OPS_TYPE {HIDE,TRASH,DELETE_PERMANENTLY,+ SET_FAVORITE}export async function downloadFile(file: EnteFile) {@@ -598,6 +599,7 @@ export const handleFileOps = async (| ((prev: { files: EnteFile[] }) => { files: EnteFile[] }),) => void,setFilesDownloadProgressAttributesCreator: SetFilesDownloadProgressAttributesCreator,+ updateFavItemIds: (ids: Set<Number>) => void,) => {switch (ops) {case FILE_OPS_TYPE.TRASH:@@ -629,6 +631,10 @@ export const handleFileOps = async (case FILE_OPS_TYPE.UNARCHIVE:await changeFilesVisibility(files, ItemVisibility.visible);break;+ case FILE_OPS_TYPE.SET_FAVORITE:+ await setBulkFavorite(files);+ updateFavItemIds(new Set(files.map(f=>f.id)))+ break;}};@@ -681,3 +687,11 @@ const fixTimeHelper = async () => {setFixCreationTimeAttributes({ files: selectedFiles });};++const setBulkFavorite = async (files: EnteFile []) => {+ try {+ await addMultipleToFavorites(files);+ } catch (e) {+ log.error("Could not add to favorites", e);+ }+}