Skip to content

armgit / ente

Public Imported from GitHub
0

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

Tweak progress

Manav Rathi7348170a366a
diff --git a/web/packages/new/photos/pages/duplicates.tsx b/web/packages/new/photos/pages/duplicates.tsx
index e0fef305c0..5802ad6b95 100644
--- a/web/packages/new/photos/pages/duplicates.tsx
+++ b/web/packages/new/photos/pages/duplicates.tsx
@@ -25,7 +25,6 @@ import {
styled,
Tooltip,
Typography,
- type LinearProgressProps,
} from "@mui/material";
import { useRouter } from "next/router";
import React, {
@@ -286,6 +285,7 @@ const dedupReducer: React.Reducer<DedupState, DedupAction> = (
duplicateGroups,
prunableCount,
prunableSize,
+ dedupeProgress: undefined,
};
}
}
@@ -651,7 +651,13 @@ const DeduplicateButton: React.FC<DeduplicateButtonProps> = ({
}}
>
{dedupeProgress !== undefined ? (
- <LinearProgressWithLabel value={dedupeProgress} />
+ <LinearProgress
+ sx={{ borderRadius: "4px" }}
+ variant={
+ dedupeProgress === 0 ? "indeterminate" : "determinate"
+ }
+ value={dedupeProgress}
+ />
) : (
<>
<Typography>
@@ -665,16 +671,3 @@ const DeduplicateButton: React.FC<DeduplicateButtonProps> = ({
</Stack>
</FocusVisibleButton>
);
-
-interface LinearProgressWithLabelProps {
- value: Exclude<LinearProgressProps["value"], undefined>;
-}
-
-export const LinearProgressWithLabel: React.FC<
- LinearProgressWithLabelProps
-> = ({ value }) => (
- <Stack direction="row" sx={{ flex: 1, gap: 2, alignItems: "center" }}>
- <LinearProgress sx={{ flex: 1 }} variant="determinate" value={value} />
- <Typography sx={{ minWidth: "3ex" }}>`{Math.round(value)}%</Typography>
- </Stack>
-);
diff --git a/web/packages/new/photos/services/dedup.ts b/web/packages/new/photos/services/dedup.ts
index a7d8b85754..4304f9e749 100644
--- a/web/packages/new/photos/services/dedup.ts
+++ b/web/packages/new/photos/services/dedup.ts
@@ -222,9 +222,15 @@ export const removeSelectedDuplicateGroups = async (
onProgress: (progress: number) => void,
) => {
const selectedDuplicateGroups = duplicateGroups.filter((g) => g.isSelected);
+ let i = selectedDuplicateGroups.length;
for (const duplicateGroup of selectedDuplicateGroups) {
await removeDuplicateGroup(duplicateGroup);
console.log(onProgress);
+ onProgress(
+ ((selectedDuplicateGroups.length - i++) /
+ selectedDuplicateGroups.length) *
+ -100,
+ );
}
return new Set(selectedDuplicateGroups.map((g) => g.id));
};