Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

chore(gallery):notification-added-for-adding-person

Aswin Asokb654046ebed5
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 361f7fb864..a26743560e 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -3,6 +3,7 @@
/* eslint-disable react-hooks/exhaustive-deps */
/* eslint-disable @typescript-eslint/no-floating-promises */
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
+import CheckCircleIcon from "@mui/icons-material/CheckCircle";
import FileUploadOutlinedIcon from "@mui/icons-material/FileUploadOutlined";
import MenuIcon from "@mui/icons-material/Menu";
import { IconButton, Link, Stack, Typography } from "@mui/material";
@@ -163,8 +164,12 @@ import {
*/
const Page: React.FC = () => {
const { logout, showMiniDialog, onGenericError } = useBaseContext();
- const { showLoadingBar, hideLoadingBar, watchFolderView } =
- usePhotosAppContext();
+ const {
+ showLoadingBar,
+ hideLoadingBar,
+ watchFolderView,
+ showNotification,
+ } = usePhotosAppContext();
const isOffline = useIsOffline();
const [state, dispatch] = useGalleryReducer();
@@ -950,8 +955,22 @@ const Page: React.FC = () => {
selectedFiles.map((f) => f.id),
);
clearSelection();
+ const personName = namedPeople.find((p) => p.id === personID)?.name;
+ showNotification({
+ color: "secondary",
+ startIcon: <CheckCircleIcon />,
+ title: t("added_to_person"),
+ caption: personName,
+ autoHideDuration: 3000,
+ });
},
- [selected, filteredFiles, clearSelection],
+ [
+ selected,
+ filteredFiles,
+ clearSelection,
+ showNotification,
+ namedPeople,
+ ],
);
// Handler for selecting a person from the context menu assign person dialog
diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.json
index ce8d5054d4..84c1b8ab18 100644
--- a/web/packages/base/locales/en-US/translation.json
+++ b/web/packages/base/locales/en-US/translation.json
@@ -402,6 +402,7 @@
"upload_to_album": "Upload to album",
"add_to_album": "Add to album",
"added_to_album": "Added to album",
+ "added_to_person": "Added to person",
"move_to_album": "Move to album",
"unhide_to_album": "Unhide to album",
"restore_to_album": "Restore to album",
diff --git a/web/packages/new/photos/components/Notification.tsx b/web/packages/new/photos/components/Notification.tsx
index 26ecfc7db0..9ee62d48d4 100644
--- a/web/packages/new/photos/components/Notification.tsx
+++ b/web/packages/new/photos/components/Notification.tsx
@@ -72,6 +72,11 @@ export interface NotificationAttributes {
* notification body.
*/
onEndIconClick?: () => void;
+ /**
+ * If set, the notification will automatically close after this many
+ * milliseconds.
+ */
+ autoHideDuration?: number;
}
type NotificationProps = ModalVisibilityProps & {
@@ -97,6 +102,11 @@ type NotificationProps = ModalVisibilityProps & {
* Default: "bottom".
*/
vertical?: "top" | "bottom";
+ /**
+ * If set, the notification will automatically close after this many
+ * milliseconds.
+ */
+ autoHideDuration?: number;
/**
* sx props to customize the appearance of the underlying MUI
* {@link Snackbar}.
@@ -121,6 +131,7 @@ export const Notification: React.FC<NotificationProps> = ({
onClose,
horizontal,
vertical,
+ autoHideDuration,
sx,
attributes,
keepOpenOnClick,
@@ -136,6 +147,7 @@ export const Notification: React.FC<NotificationProps> = ({
endIcon,
onClick,
onEndIconClick,
+ autoHideDuration: attrAutoHideDuration,
} = attributes;
const handleClose: React.MouseEventHandler = (event) => {
@@ -160,6 +172,8 @@ export const Notification: React.FC<NotificationProps> = ({
return (
<Snackbar
open={open}
+ autoHideDuration={attrAutoHideDuration ?? autoHideDuration}
+ onClose={onClose}
anchorOrigin={{
horizontal: horizontal ?? "right",
vertical: vertical ?? "bottom",