π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[locker] Improve search responsiveness with deferred input and memoized cards
Neeraj Gupta42135f427911
diff --git a/web/apps/locker/src/components/ItemCard.tsx b/web/apps/locker/src/components/ItemCard.tsxindex 9487c58cc8..d1bbf74018 100644--- a/web/apps/locker/src/components/ItemCard.tsx+++ b/web/apps/locker/src/components/ItemCard.tsx@@ -62,7 +62,7 @@ interface ItemCardProps {* A file/item row matching the Figma design:* Light rounded card background β colored icon (in rounded square) β title β actions*/-export const ItemCard: React.FC<ItemCardProps> = ({+export const ItemCard: React.FC<ItemCardProps> = React.memo(function ItemCard({item,masterKey,onClick,@@ -79,7 +79,7 @@ export const ItemCard: React.FC<ItemCardProps> = ({selected,onToggleSelection,onLongPressSelect,-}) => {+}) {const [downloadError, setDownloadError] = useState(false);const [downloading, setDownloading] = useState(false);const [downloadProgress, setDownloadProgress] = useState<number | null>(@@ -367,7 +367,7 @@ export const ItemCard: React.FC<ItemCardProps> = ({/></>);-};+});// ---------------------------------------------------------------------------// Overflow menu for item actionsdiff --git a/web/apps/locker/src/components/LockerNavbar.tsx b/web/apps/locker/src/components/LockerNavbar.tsxindex dd30fb2693..b59df11aca 100644--- a/web/apps/locker/src/components/LockerNavbar.tsx+++ b/web/apps/locker/src/components/LockerNavbar.tsx@@ -11,7 +11,7 @@ import {Typography,} from "@mui/material";import { t } from "i18next";-import React from "react";+import React, { useEffect, useDeferredValue, useState } from "react";const contentMaxWidth = 560;@@ -41,7 +41,20 @@ export const LockerNavbar: React.FC<LockerNavbarProps> = ({stickyTop = 0,searchTerm,onSearchTermChange,-}) => (+}) => {+ const [localSearchTerm, setLocalSearchTerm] = useState(searchTerm);+ const deferredSearchTerm = useDeferredValue(localSearchTerm);++ useEffect(() => {+ onSearchTermChange(deferredSearchTerm);+ }, [deferredSearchTerm, onSearchTermChange]);++ // Sync local state when parent resets searchTerm (e.g. navigation).+ useEffect(() => {+ setLocalSearchTerm(searchTerm);+ }, [searchTerm]);++ return (<Boxsx={{position: "sticky",@@ -89,8 +102,8 @@ export const LockerNavbar: React.FC<LockerNavbarProps> = ({<TextFieldsize="small"placeholder={t("searchHint")}- value={searchTerm}- onChange={(event) => onSearchTermChange(event.target.value)}+ value={localSearchTerm}+ onChange={(event) => setLocalSearchTerm(event.target.value)}variant="outlined"fullWidthslotProps={{@@ -124,7 +137,8 @@ export const LockerNavbar: React.FC<LockerNavbarProps> = ({/></Box></Box>-);+ );+};export const LockerUnstableToast: React.FC = () => (<Box sx={{ position: "sticky", top: 0, zIndex: 2 }}>