Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix: add error handling for ManageTemplate component

anandbaburajan83e1d28dedc1
diff --git a/web/apps/photos/src/components/Collections/CollectionShare.tsx b/web/apps/photos/src/components/Collections/CollectionShare.tsx
index 4f747d371e..779a43e44d 100644
--- a/web/apps/photos/src/components/Collections/CollectionShare.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionShare.tsx
@@ -1831,6 +1831,7 @@ const ManageTemplate: React.FC<ManageTemplateProps> = ({
}) => {
const { show: showTemplateOptions, props: templateOptionsVisibilityProps } =
useModalVisibility();
+ const [errorMessage, setErrorMessage] = useState("");
const options = useMemo(() => templateOptions(), []);
@@ -1841,12 +1842,14 @@ const ManageTemplate: React.FC<ManageTemplateProps> = ({
if (value === currentTemplate) return;
setBlockingLoad(true);
+ setErrorMessage("");
try {
await updateCollectionTemplate(collection, value);
await onRemotePull({ silent: true });
templateOptionsVisibilityProps.onClose();
} catch (e) {
log.error("Could not update collection template", e);
+ setErrorMessage(t("generic_error"));
} finally {
setBlockingLoad(false);
}
@@ -1890,6 +1893,14 @@ const ManageTemplate: React.FC<ManageTemplateProps> = ({
</React.Fragment>
))}
</RowButtonGroup>
+ {errorMessage && (
+ <Typography
+ variant="small"
+ sx={{ color: "critical.main", textAlign: "center" }}
+ >
+ {errorMessage}
+ </Typography>
+ )}
</Stack>
</TitledNestedSidebarDrawer>
</>