Skip to content

armgit / ente

Public Imported from GitHub
0

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

[web] Centralize notification timeout defaults

AswinAsokaf412347262d
diff --git a/web/apps/photos/src/pages/_app.tsx b/web/apps/photos/src/pages/_app.tsx
index 66a8fbc4db..4caa47ee35 100644
--- a/web/apps/photos/src/pages/_app.tsx
+++ b/web/apps/photos/src/pages/_app.tsx
@@ -179,12 +179,7 @@ const App: React.FC<PhotosAppProps> = ({ Component, pageProps }) => {
<ThemedLoadingBar ref={loadingBarRef} />
<AttributedMiniDialog {...miniDialogProps} appearance="centered" />
- <Notification
- {...notificationProps}
- autoHideDuration={
- notificationProps.attributes?.onClick ? null : undefined
- }
- />
+ <Notification {...notificationProps} />
{isDesktop && (
<WindowTitlebar {...{ isFileViewerOpen }}>
diff --git a/web/packages/base/components/Notification.tsx b/web/packages/base/components/Notification.tsx
index d443130ab2..f3b6823236 100644
--- a/web/packages/base/components/Notification.tsx
+++ b/web/packages/base/components/Notification.tsx
@@ -61,7 +61,7 @@ export const Notification: React.FC<NotificationProps> = ({
open,
onClose,
horizontal = "right",
- autoHideDuration = 3000,
+ autoHideDuration,
sx,
attributes,
keepOpenOnClick,
@@ -79,6 +79,12 @@ export const Notification: React.FC<NotificationProps> = ({
onClick,
onEndIconClick,
} = attributes;
+ const resolvedAutoHideDuration =
+ autoHideDuration === undefined
+ ? onClick
+ ? null
+ : 3000
+ : autoHideDuration;
const neutral = !color || color === "inherit";
const buttonSx = {
...actionButtonSx,
@@ -157,7 +163,7 @@ export const Notification: React.FC<NotificationProps> = ({
return (
<Snackbar
open={open}
- autoHideDuration={autoHideDuration}
+ autoHideDuration={resolvedAutoHideDuration}
onClose={(_, reason) => {
if (reason === "timeout") onClose();
}}