Skip to content

armgit / ente

Public Imported from GitHub
0

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

remove-deadcode

Aswin Asokfa7cf31bd5d4
diff --git a/web/apps/ensu/package.json b/web/apps/ensu/package.json
index ddd4fd1561..a1ffd9f79d 100644
--- a/web/apps/ensu/package.json
+++ b/web/apps/ensu/package.json
@@ -5,7 +5,6 @@
"dependencies": {
"@hugeicons/core-free-icons": "1.2.1",
"@hugeicons/react": "1.1.6",
- "@rive-app/canvas": "2.37.8",
"@tauri-apps/api": "2.11.0",
"@tauri-apps/plugin-dialog": "2.7.1",
"@tauri-apps/plugin-fs": "2.5.1",
diff --git a/web/apps/ensu/public/animations/ensu.riv b/web/apps/ensu/public/animations/ensu.riv
deleted file mode 100644
index 9eb57731ca..0000000000
Binary files a/web/apps/ensu/public/animations/ensu.riv and /dev/null differ
diff --git a/web/apps/ensu/src/components/chat/HoverRiveLogo.tsx b/web/apps/ensu/src/components/chat/HoverRiveLogo.tsx
deleted file mode 100644
index e90aa8691b..0000000000
--- a/web/apps/ensu/src/components/chat/HoverRiveLogo.tsx
+++ /dev/null
@@ -1,194 +0,0 @@
-import { Box } from "@mui/material";
-import { useRouter } from "next/router";
-import { memo, useEffect, useRef, useState } from "react";
-
-interface HoverRiveLogoProps {
- staticSrc: string;
- alt: string;
- sizePx?: number;
-}
-
-type RivePlaybackTarget = string | string[];
-
-interface RiveInstance {
- cleanup?: () => void;
- resizeDrawingSurfaceToCanvas?: () => void;
- play?: (animation?: RivePlaybackTarget) => void;
- pause?: () => void;
- stop?: () => void;
- reset?: () => void;
- animationNames?: string[];
- stateMachineNames?: string[];
-}
-
-const RIVE_SRC = "/animations/ensu.riv";
-
-const HoverRiveLogo = memo(
- ({ staticSrc, alt, sizePx = 28 }: HoverRiveLogoProps) => {
- const canvasRef = useRef<HTMLCanvasElement | null>(null);
- const riveRef = useRef<RiveInstance | null>(null);
- const playbackTargetRef = useRef<RivePlaybackTarget | undefined>(
- undefined,
- );
- const [isHovering, setIsHovering] = useState(false);
- const [isReady, setIsReady] = useState(false);
- const [failedToLoad, setFailedToLoad] = useState(false);
- const { basePath } = useRouter();
- const riveSrc = `${basePath}${RIVE_SRC}`;
-
- useEffect(() => {
- if (typeof window === "undefined") return;
-
- let canceled = false;
-
- const initialize = async () => {
- try {
- const rive = await import("@rive-app/canvas");
- if (canceled || !canvasRef.current) return;
-
- const { Alignment, Fit, Layout, Rive } = rive;
- riveRef.current = new Rive({
- src: riveSrc,
- canvas: canvasRef.current,
- autoplay: false,
- layout: new Layout({
- fit: Fit.Contain,
- alignment: Alignment.Center,
- }),
- onLoad: () => {
- try {
- riveRef.current?.resizeDrawingSurfaceToCanvas?.();
-
- const stateMachineNames =
- riveRef.current?.stateMachineNames ?? [];
- const animationNames =
- riveRef.current?.animationNames ?? [];
-
- if (stateMachineNames.length > 0) {
- playbackTargetRef.current =
- stateMachineNames[0];
- } else if (animationNames.length > 1) {
- playbackTargetRef.current = animationNames;
- } else if (animationNames.length === 1) {
- playbackTargetRef.current =
- animationNames[0];
- }
-
- riveRef.current?.pause?.();
- } catch {
- // The logo animation is decorative; ignore
- // Rive runtime errors.
- }
- if (!canceled) {
- setIsReady(true);
- }
- },
- onLoadError: () => {
- if (!canceled) {
- setFailedToLoad(true);
- }
- },
- });
- } catch {
- if (!canceled) {
- setFailedToLoad(true);
- }
- }
- };
-
- void initialize();
-
- return () => {
- canceled = true;
- try {
- riveRef.current?.cleanup?.();
- } catch {
- // The logo animation is decorative; ignore Rive runtime
- // errors.
- }
- riveRef.current = null;
- playbackTargetRef.current = undefined;
- };
- }, [riveSrc]);
-
- const startAnimation = () => {
- setIsHovering(true);
- try {
- riveRef.current?.reset?.();
- const target = playbackTargetRef.current;
- if (target) {
- riveRef.current?.play?.(target);
- } else {
- riveRef.current?.play?.();
- }
- } catch {
- // The logo animation is decorative; ignore Rive runtime
- // errors.
- }
- };
-
- const stopAnimation = () => {
- setIsHovering(false);
- try {
- riveRef.current?.pause?.();
- riveRef.current?.stop?.();
- } catch {
- // The logo animation is decorative; ignore Rive runtime
- // errors.
- }
- };
-
- const canShowRive = isReady && !failedToLoad;
- const showRive = isHovering && canShowRive;
-
- return (
- <Box
- onMouseEnter={startAnimation}
- onMouseLeave={stopAnimation}
- sx={{
- position: "relative",
- width: sizePx,
- height: sizePx,
- display: "inline-flex",
- alignItems: "center",
- justifyContent: "center",
- flexShrink: 0,
- }}
- >
- <Box
- component="img"
- src={staticSrc}
- alt={alt}
- sx={{
- width: "100%",
- height: "100%",
- display: "block",
- opacity: showRive ? 0 : 1,
- transition: "opacity 160ms ease-out",
- }}
- />
- <Box
- component="canvas"
- ref={canvasRef}
- aria-label={`${alt} animation`}
- sx={{
- position: "absolute",
- inset: 0,
- width: "100%",
- height: "100%",
- display: "block",
- opacity: showRive ? 1 : 0,
- transition: "opacity 160ms ease-out",
- transform: "scale(1.08)",
- transformOrigin: "50% 50%",
- pointerEvents: "none",
- }}
- />
- </Box>
- );
- },
-);
-
-HoverRiveLogo.displayName = "HoverRiveLogo";
-
-export default HoverRiveLogo;
diff --git a/web/apps/ensu/src/services/chat/md5.ts b/web/apps/ensu/src/services/chat/md5.ts
deleted file mode 100644
index 0ee699b935..0000000000
--- a/web/apps/ensu/src/services/chat/md5.ts
+++ /dev/null
@@ -1,109 +0,0 @@
-const shifts = new Uint8Array([
- 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 5, 9, 14, 20, 5,
- 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11,
- 16, 23, 4, 11, 16, 23, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10,
- 15, 21,
-]);
-
-const constants = (() => {
- const k = new Uint32Array(64);
- for (let i = 0; i < 64; i += 1) {
- k[i] = Math.floor(Math.abs(Math.sin(i + 1)) * 2 ** 32);
- }
- return k;
-})();
-
-const leftRotate = (value: number, amount: number) =>
- (value << amount) | (value >>> (32 - amount));
-
-const toUint8ArrayLE = (word: number) => {
- const bytes = new Uint8Array(4);
- bytes[0] = word & 0xff;
- bytes[1] = (word >>> 8) & 0xff;
- bytes[2] = (word >>> 16) & 0xff;
- bytes[3] = (word >>> 24) & 0xff;
- return bytes;
-};
-
-const bytesToBase64 = (bytes: Uint8Array) => {
- if (typeof Buffer !== "undefined") {
- return Buffer.from(bytes).toString("base64");
- }
- let binary = "";
- for (const byte of bytes) {
- binary += String.fromCharCode(byte);
- }
- return btoa(binary);
-};
-
-export const computeMd5Base64 = (data: Uint8Array): string => {
- const originalLengthBits = data.length * 8;
- const paddedLength = (((data.length + 8) >>> 6) << 4) + 16;
- const words = new Uint32Array(paddedLength);
-
- for (const [i, value] of data.entries()) {
- const wordIndex = i >> 2;
- const existing = words[wordIndex] ?? 0;
- words[wordIndex] = existing | (value << ((i % 4) * 8));
- }
-
- const paddingIndex = data.length >> 2;
- const paddingExisting = words[paddingIndex] ?? 0;
- words[paddingIndex] = paddingExisting | (0x80 << ((data.length % 4) * 8));
- words[paddedLength - 2] = originalLengthBits & 0xffffffff;
- words[paddedLength - 1] = (originalLengthBits / 0x100000000) | 0;
-
- let a = 0x67452301;
- let b = 0xefcdab89;
- let c = 0x98badcfe;
- let d = 0x10325476;
-
- for (let i = 0; i < words.length; i += 16) {
- let A = a;
- let B = b;
- let C = c;
- let D = d;
-
- for (let j = 0; j < 64; j += 1) {
- let f: number;
- let g: number;
-
- if (j < 16) {
- f = (B & C) | (~B & D);
- g = j;
- } else if (j < 32) {
- f = (D & B) | (~D & C);
- g = (5 * j + 1) % 16;
- } else if (j < 48) {
- f = B ^ C ^ D;
- g = (3 * j + 5) % 16;
- } else {
- f = C ^ (B | ~D);
- g = (7 * j) % 16;
- }
-
- const temp = D;
- D = C;
- C = B;
- const word = words[i + g] ?? 0;
- const constant = constants[j] ?? 0;
- const shift = shifts[j] ?? 0;
- const sum = (A + f + constant + word) >>> 0;
- B = (B + leftRotate(sum, shift)) >>> 0;
- A = temp;
- }
-
- a = (a + A) >>> 0;
- b = (b + B) >>> 0;
- c = (c + C) >>> 0;
- d = (d + D) >>> 0;
- }
-
- const digest = new Uint8Array(16);
- digest.set(toUint8ArrayLE(a), 0);
- digest.set(toUint8ArrayLE(b), 4);
- digest.set(toUint8ArrayLE(c), 8);
- digest.set(toUint8ArrayLE(d), 12);
-
- return bytesToBase64(digest);
-};
diff --git a/web/apps/locker/src/components/CollectionSidebar.tsx b/web/apps/locker/src/components/CollectionSidebar.tsx
deleted file mode 100644
index 6b323ab45d..0000000000
--- a/web/apps/locker/src/components/CollectionSidebar.tsx
+++ /dev/null
@@ -1,342 +0,0 @@
-import type { LockerCollection } from "@/types";
-import { isImportantCollection, visibleLockerCollections } from "@/types";
-import CloudQueueOutlinedIcon from "@mui/icons-material/CloudQueueOutlined";
-import DeleteOutlinedIcon from "@mui/icons-material/DeleteOutlined";
-import GridViewOutlinedIcon from "@mui/icons-material/GridViewOutlined";
-import HomeOutlinedIcon from "@mui/icons-material/HomeOutlined";
-import LabelOutlinedIcon from "@mui/icons-material/LabelOutlined";
-import LogoutOutlinedIcon from "@mui/icons-material/LogoutOutlined";
-import StarIcon from "@mui/icons-material/Star";
-import {
- Badge,
- Box,
- Divider,
- List,
- ListItemButton,
- ListItemIcon,
- ListItemText,
- Stack,
- Typography,
-} from "@mui/material";
-import { useBaseContext } from "ente-base/context";
-import { t } from "i18next";
-import React, { useMemo } from "react";
-
-export const SIDEBAR_WIDTH = 280;
-
-interface CollectionSidebarProps {
- collections: LockerCollection[];
- selectedCollectionID: number | null;
- isTrashView: boolean;
- isCollectionsView: boolean;
- onSelectCollection: (collectionID: number | null) => void;
- onSelectCollections: () => void;
- onSelectTrash: () => void;
- trashItemCount: number;
- userDetails?: {
- email: string;
- usage: number;
- storageLimit: number;
- fileCount: number;
- lockerFileLimit: number;
- };
-}
-
-export const CollectionSidebar: React.FC<CollectionSidebarProps> = ({
- collections,
- selectedCollectionID,
- isTrashView,
- isCollectionsView,
- onSelectCollection,
- onSelectCollections,
- onSelectTrash,
- trashItemCount,
- userDetails,
-}) => {
- const { logout } = useBaseContext();
- const displayCollections = useMemo(
- () => visibleLockerCollections(collections),
- [collections],
- );
-
- const totalItems = collections.reduce((sum, c) => sum + c.items.length, 0);
- const isHomeSelected =
- !isTrashView && !isCollectionsView && selectedCollectionID === null;
- const usageLimit = userDetails
- ? Math.max(userDetails.lockerFileLimit, 1)
- : 100;
- const usageProgress = userDetails
- ? Math.min((userDetails.fileCount / usageLimit) * 100, 100)
- : 0;
- const formattedUsage = new Intl.NumberFormat().format(
- userDetails?.fileCount ?? 0,
- );
- const formattedUsageLimit = new Intl.NumberFormat().format(usageLimit);
-
- return (
- <Box
- sx={{
- width: SIDEBAR_WIDTH,
- flexShrink: 0,
- display: "flex",
- flexDirection: "column",
- borderRight: 1,
- borderColor: "divider",
- backgroundColor: "background.paper",
- height: "calc(100vh - 72px)",
- }}
- >
- <Stack sx={{ px: 1.5, py: 2, gap: 2, flex: 1, minHeight: 0 }}>
- {userDetails && (
- <Box sx={{ px: 0.5 }}>
- {userDetails.email && (
- <Typography
- variant="small"
- sx={{
- color: "text.muted",
- mb: 1.25,
- display: "block",
- wordBreak: "break-all",
- }}
- >
- {userDetails.email}
- </Typography>
- )}
-
- <Box
- sx={{
- p: 1.5,
- borderRadius: "18px",
- background:
- "linear-gradient(135deg, #1071FF 0%, #0056CC 100%)",
- color: "#fff",
- }}
- >
- <Stack
- direction="row"
- sx={{ gap: 1.5, alignItems: "center" }}
- >
- <Box
- sx={{
- width: 40,
- height: 40,
- borderRadius: "12px",
- backgroundColor:
- "rgba(255, 255, 255, 0.1)",
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- flexShrink: 0,
- }}
- >
- <CloudQueueOutlinedIcon
- sx={{ fontSize: 20 }}
- />
- </Box>
- <Stack sx={{ gap: 1, flex: 1, minWidth: 0 }}>
- <Stack
- direction="row"
- sx={{
- alignItems: "baseline",
- justifyContent: "space-between",
- gap: 1,
- }}
- >
- <Typography
- variant="small"
- sx={{
- fontWeight: "bold",
- color: "#fff",
- }}
- >
- {t("usage")}
- </Typography>
- <Typography
- variant="mini"
- sx={{
- color: "rgba(255,255,255,0.72)",
- whiteSpace: "nowrap",
- }}
- >
- {t("lockerUsageSummary", {
- used: formattedUsage,
- total: formattedUsageLimit,
- })}
- </Typography>
- </Stack>
- <Box
- sx={{
- height: 4,
- borderRadius: 999,
- backgroundColor:
- "rgba(255,255,255,0.22)",
- overflow: "hidden",
- }}
- >
- <Box
- sx={{
- width: `${usageProgress}%`,
- minWidth:
- usageProgress > 0 ? 8 : 0,
- height: "100%",
- borderRadius: 999,
- backgroundColor: "#fff",
- }}
- />
- </Box>
- </Stack>
- </Stack>
- </Box>
- </Box>
- )}
-
- <Divider />
-
- <List disablePadding sx={{ gap: 0.5, display: "grid" }}>
- <SidebarRow
- label={t("home")}
- icon={<HomeOutlinedIcon fontSize="small" />}
- badgeContent={totalItems}
- selected={isHomeSelected}
- onClick={() => onSelectCollection(null)}
- />
- <SidebarRow
- label={t("menuCollections")}
- icon={<GridViewOutlinedIcon fontSize="small" />}
- badgeContent={displayCollections.length}
- selected={isCollectionsView}
- onClick={onSelectCollections}
- />
- <SidebarRow
- label={t("menuTrash")}
- icon={<DeleteOutlinedIcon fontSize="small" />}
- badgeContent={trashItemCount}
- selected={isTrashView}
- onClick={onSelectTrash}
- />
- </List>
-
- <Divider />
-
- <Box sx={{ px: 1 }}>
- <Typography
- variant="mini"
- sx={{
- color: "text.faint",
- textTransform: "uppercase",
- letterSpacing: "0.08em",
- fontWeight: "bold",
- }}
- >
- {t("collections")}
- </Typography>
- </Box>
-
- <Box sx={{ flex: 1, minHeight: 0, overflowY: "auto", pr: 0.5 }}>
- <List disablePadding sx={{ gap: 0.5, display: "grid" }}>
- {displayCollections.map((collection) => (
- <SidebarRow
- key={collection.id}
- label={collection.name}
- icon={
- isImportantCollection(collection) ? (
- <StarIcon
- fontSize="small"
- sx={{ color: "primary.main" }}
- />
- ) : (
- <LabelOutlinedIcon fontSize="small" />
- )
- }
- badgeContent={collection.items.length}
- selected={
- !isTrashView &&
- !isCollectionsView &&
- selectedCollectionID === collection.id
- }
- onClick={() =>
- onSelectCollection(collection.id)
- }
- />
- ))}
- </List>
- </Box>
- </Stack>
-
- <Box
- sx={{
- px: 2,
- pt: 1.25,
- pb: 2,
- borderTop: 1,
- borderColor: "divider",
- backgroundColor: "background.paper",
- }}
- >
- <SidebarRow
- label={t("logout")}
- icon={<LogoutOutlinedIcon fontSize="small" />}
- selected={false}
- onClick={logout}
- color="critical.main"
- />
- </Box>
- </Box>
- );
-};
-
-const SidebarRow: React.FC<{
- label: string;
- icon: React.ReactNode;
- badgeContent?: number;
- selected: boolean;
- onClick: () => void;
- color?: string;
-}> = ({ label, icon, badgeContent, selected, onClick, color }) => (
- <ListItemButton
- selected={selected}
- onClick={onClick}
- sx={(theme) => ({
- borderRadius: 2,
- px: 1.25,
- color,
- border: "1px solid transparent",
- ...(selected && {
- color: color ?? "primary.main",
- borderColor: theme.vars.palette.primary.main,
- backgroundColor: "rgba(16, 113, 255, 0.10)",
- }),
- "&.Mui-selected": { backgroundColor: "rgba(16, 113, 255, 0.10)" },
- "&.Mui-selected:hover": {
- backgroundColor: "rgba(16, 113, 255, 0.14)",
- },
- "&:hover": {
- backgroundColor: selected
- ? "rgba(16, 113, 255, 0.14)"
- : theme.vars.palette.fill.faint,
- },
- })}
- >
- <ListItemIcon sx={{ minWidth: 36, color: "inherit" }}>
- {icon}
- </ListItemIcon>
- <ListItemText
- primary={label}
- slotProps={{
- primary: {
- variant: "body",
- noWrap: true,
- sx: { fontWeight: selected ? "bold" : "medium" },
- },
- }}
- />
- {typeof badgeContent === "number" && (
- <Badge
- badgeContent={badgeContent}
- color={selected ? "primary" : "default"}
- max={999}
- sx={{ mr: 1 }}
- />
- )}
- </ListItemButton>
-);
diff --git a/web/package-lock.json b/web/package-lock.json
index b6038d438a..4f48978897 100644
--- a/web/package-lock.json
+++ b/web/package-lock.json
@@ -172,7 +172,6 @@
"dependencies": {
"@hugeicons/core-free-icons": "1.2.1",
"@hugeicons/react": "1.1.6",
- "@rive-app/canvas": "2.37.8",
"@tauri-apps/api": "2.11.0",
"@tauri-apps/plugin-dialog": "2.7.1",
"@tauri-apps/plugin-fs": "2.5.1",
@@ -2648,12 +2647,6 @@
"react-dom": "^19.0.0"
}
},
- "node_modules/@rive-app/canvas": {
- "version": "2.37.8",
- "resolved": "https://registry.npmjs.org/@rive-app/canvas/-/canvas-2.37.8.tgz",
- "integrity": "sha512-nffrPG+VkBKHAxZdcqYlP5M+n/mOAoagj774HH397UPTsfC27gwQURg64i6dX7WswMc5qIVX0rzCrZ86Wb2HOA==",
- "license": "MIT"
- },
"node_modules/@rolldown/binding-android-arm64": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.1.3.tgz",
diff --git a/web/packages/accounts/pages/passkeys/recover.tsx b/web/packages/accounts/pages/passkeys/recover.tsx
deleted file mode 100644
index 6d29d53c6a..0000000000
--- a/web/packages/accounts/pages/passkeys/recover.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import Page_ from "../two-factor/recover";
-
-const Page = () => <Page_ twoFactorType="passkey" />;
-
-export default Page;