From ea51071538fee1284a9bd8651a72e515c2001d53 Mon Sep 17 00:00:00 2001 From: Varun Raj Date: Tue, 25 Mar 2025 22:31:40 +0530 Subject: [PATCH] refactor: clean up imports and remove unused components - Removed unused imports and components across various files to streamline the codebase. - Simplified the structure of components such as AlbumImages, AlbumPeople, and others by eliminating unnecessary dependencies. - Enhanced overall readability and maintainability of the code. --- .eslintrc.json | 6 ++++- src/components/albums/info/AlbumImages.tsx | 2 -- src/components/albums/info/AlbumPeople.tsx | 4 --- .../PotentialAlbumsAssets.tsx | 4 +-- .../potential-albums/PotentialAlbumsDates.tsx | 4 +-- .../missing-location/MissingLocationDates.tsx | 5 ++-- .../TagMissingLocationDialog/Map.tsx | 4 +-- .../TagMissingLocationOSMSearchAndAdd.tsx | 1 - .../TagMissingLocationSearchAndAdd.tsx | 2 -- .../TagMissingLocationSearchLatLong.tsx | 7 +---- src/components/layouts/PageLayout.tsx | 2 -- src/components/layouts/RootLayout.tsx | 1 - src/components/people/PeopleFilters.tsx | 1 - src/components/people/PersonHideCell.tsx | 5 ---- src/components/people/PersonItem.tsx | 2 +- .../people/info/PersonAlbumList.tsx | 1 - src/components/shared/AlbumDropdown.tsx | 1 - src/components/shared/ErrorBlock.tsx | 2 -- src/components/shared/FloatingBar.tsx | 1 - src/components/shared/Header.tsx | 18 +------------ src/components/shared/PeopleList.tsx | 1 - src/components/shared/ShareAssetsTrigger.tsx | 1 - src/components/shared/ThemeSwitcher.tsx | 3 +-- src/pages/api/albums/[id]/assets.ts | 5 +--- src/pages/api/albums/[id]/people.ts | 6 ++--- src/pages/api/albums/[id]/public-info.ts | 1 - src/pages/api/albums/list.ts | 1 - .../api/albums/potential-albums-assets.ts | 5 +--- .../api/albums/potential-albums-dates.ts | 4 +-- src/pages/api/analytics/exif/[property].ts | 1 - src/pages/api/analytics/exif/storage.ts | 1 - .../api/assets/missing-location-albums.ts | 1 - .../api/assets/missing-location-dates.ts | 2 -- src/pages/api/find/search.ts | 10 +++---- src/pages/api/immich-proxy/[...path].ts | 2 -- src/pages/api/people/[id]/similar-faces.ts | 4 +-- src/pages/api/share-link/[token]/assets.ts | 2 +- src/pages/api/share-link/[token]/download.ts | 10 +------ src/pages/api/users/login.ts | 4 +-- src/pages/assets/missing-locations.tsx | 2 -- src/pages/find/index.tsx | 27 +++++++++++++------ src/pages/people/[personId].tsx | 5 +--- src/pages/s/[token].tsx | 2 +- 43 files changed, 52 insertions(+), 121 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 7d8b7fc..474b69e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -6,5 +6,9 @@ "files": ["remotion/*.{ts,tsx}"], "extends": ["plugin:@remotion/recommended"] } - ] + ], + "rules": { + "react-hooks/exhaustive-deps": "off", + "@next/next/no-img-element": "off" + } } diff --git a/src/components/albums/info/AlbumImages.tsx b/src/components/albums/info/AlbumImages.tsx index c040931..f7b1b3e 100644 --- a/src/components/albums/info/AlbumImages.tsx +++ b/src/components/albums/info/AlbumImages.tsx @@ -6,11 +6,9 @@ import { IAsset } from '@/types/asset' import React, { useEffect, useMemo, useRef, useState } from 'react' import { ExternalLink, Hourglass } from 'lucide-react'; import { useRouter } from 'next/router'; -import { CalendarArrowUp } from 'lucide-react'; import Lightbox from 'yet-another-react-lightbox'; import Captions from 'yet-another-react-lightbox/plugins/captions'; import LazyImage from '@/components/ui/lazy-image'; -import Image from 'next/image'; import { Button } from "@/components/ui/button"; import Link from "next/link"; diff --git a/src/components/albums/info/AlbumPeople.tsx b/src/components/albums/info/AlbumPeople.tsx index 5c6f03f..4981c04 100644 --- a/src/components/albums/info/AlbumPeople.tsx +++ b/src/components/albums/info/AlbumPeople.tsx @@ -1,16 +1,12 @@ import React, { useEffect, useMemo, useState } from 'react' import { IAlbum } from '@/types/album' -import { IPerson } from '@/types/person' import { getAlbumPeople } from '@/handlers/api/album.handler' import Loader from '@/components/ui/loader' import LazyImage from '@/components/ui/lazy-image' import { PERSON_THUBNAIL_PATH } from '@/config/routes' import Link from 'next/link' import { useConfig } from '@/contexts/ConfigContext' -import { Tooltip } from '@/components/ui/tooltip' import { cn } from '@/lib/utils' -import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion' -import { Users, X } from 'lucide-react' import { useRouter } from 'next/router' import Image from 'next/image' import { PersonMergeDropdown } from '@/components/people/PersonMergeDropdown' diff --git a/src/components/albums/potential-albums/PotentialAlbumsAssets.tsx b/src/components/albums/potential-albums/PotentialAlbumsAssets.tsx index 0e4752f..7934798 100644 --- a/src/components/albums/potential-albums/PotentialAlbumsAssets.tsx +++ b/src/components/albums/potential-albums/PotentialAlbumsAssets.tsx @@ -4,9 +4,9 @@ import { listPotentialAlbumsAssets } from "@/handlers/api/album.handler"; import type { IAsset } from "@/types/asset"; import React, { type MouseEvent, useEffect, useMemo, useState } from "react"; import { Gallery } from "react-grid-gallery"; -import Lightbox, { SlideImage, SlideTypes } from "yet-another-react-lightbox"; +import Lightbox from "yet-another-react-lightbox"; import Captions from "yet-another-react-lightbox/plugins/captions"; -import { CalendarArrowDown, CalendarArrowUp, Hourglass } from "lucide-react"; +import { CalendarArrowUp, Hourglass } from "lucide-react"; import Video from "yet-another-react-lightbox/plugins/video"; import { useConfig } from "@/contexts/ConfigContext"; import LazyGridImage from "@/components/ui/lazy-grid-image"; diff --git a/src/components/albums/potential-albums/PotentialAlbumsDates.tsx b/src/components/albums/potential-albums/PotentialAlbumsDates.tsx index b602fe0..8bc8c5e 100644 --- a/src/components/albums/potential-albums/PotentialAlbumsDates.tsx +++ b/src/components/albums/potential-albums/PotentialAlbumsDates.tsx @@ -2,13 +2,13 @@ import { IPotentialAlbumsDatesResponse, listPotentialAlbumsDates, } from "@/handlers/api/album.handler"; -import React, { use, useEffect, useState } from "react"; +import React, { useEffect, useState } from "react"; import PotentialDateItem from "./PotentialDateItem"; import { usePotentialAlbumContext } from "@/contexts/PotentialAlbumContext"; import { useRouter } from "next/router"; import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Button } from "@/components/ui/button"; -import { ArrowDown, ArrowUp, ArrowUpDownIcon, SortAsc, SortDesc } from "lucide-react"; +import { SortAsc, SortDesc } from "lucide-react"; export default function PotentialAlbumsDates() { const router = useRouter(); diff --git a/src/components/assets/missing-location/MissingLocationDates.tsx b/src/components/assets/missing-location/MissingLocationDates.tsx index e99bc59..668caaa 100644 --- a/src/components/assets/missing-location/MissingLocationDates.tsx +++ b/src/components/assets/missing-location/MissingLocationDates.tsx @@ -1,6 +1,5 @@ -import React, { use, useEffect, useState } from "react"; -import { usePotentialAlbumContext } from "@/contexts/PotentialAlbumContext"; -import { IMissingLocationDatesResponse, listMissingLocationAlbums, listMissingLocationDates } from "@/handlers/api/asset.handler"; +import React, { useEffect, useState } from "react"; +import { listMissingLocationAlbums, listMissingLocationDates } from "@/handlers/api/asset.handler"; import MissingLocationDateItem from "./MissingLocationDateItem"; import { useMissingLocationContext } from "@/contexts/MissingLocationContext"; import { useRouter } from "next/router"; diff --git a/src/components/assets/missing-location/TagMissingLocationDialog/Map.tsx b/src/components/assets/missing-location/TagMissingLocationDialog/Map.tsx index e3e3beb..fa3dd29 100644 --- a/src/components/assets/missing-location/TagMissingLocationDialog/Map.tsx +++ b/src/components/assets/missing-location/TagMissingLocationDialog/Map.tsx @@ -7,8 +7,8 @@ import L, { LatLngExpression } from 'leaflet'; import 'leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.webpack.css'; // Re-uses images from ~leaflet package import 'leaflet-defaulticon-compatibility'; -import { MapContainer, Marker, Popup, TileLayer, useMap, useMapEvents } from "react-leaflet"; -import { useEffect, useRef, useState } from "react"; +import { MapContainer, TileLayer, useMapEvents } from "react-leaflet"; +import { useState } from "react"; import { IPlace } from "@/types/common"; import CustomMarker from "./CustomMarker"; diff --git a/src/components/assets/missing-location/TagMissingLocationDialog/TagMissingLocationOSMSearchAndAdd.tsx b/src/components/assets/missing-location/TagMissingLocationDialog/TagMissingLocationOSMSearchAndAdd.tsx index 26a4dbb..9f74c1d 100644 --- a/src/components/assets/missing-location/TagMissingLocationDialog/TagMissingLocationOSMSearchAndAdd.tsx +++ b/src/components/assets/missing-location/TagMissingLocationDialog/TagMissingLocationOSMSearchAndAdd.tsx @@ -2,7 +2,6 @@ import ErrorBlock from "@/components/shared/ErrorBlock"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; -import { Label } from "@/components/ui/label"; import Loader from "@/components/ui/loader"; import { useToast } from "@/components/ui/use-toast"; import { cn } from "@/lib/utils"; diff --git a/src/components/assets/missing-location/TagMissingLocationDialog/TagMissingLocationSearchAndAdd.tsx b/src/components/assets/missing-location/TagMissingLocationDialog/TagMissingLocationSearchAndAdd.tsx index 3619fee..85e455c 100644 --- a/src/components/assets/missing-location/TagMissingLocationDialog/TagMissingLocationSearchAndAdd.tsx +++ b/src/components/assets/missing-location/TagMissingLocationDialog/TagMissingLocationSearchAndAdd.tsx @@ -2,13 +2,11 @@ import ErrorBlock from "@/components/shared/ErrorBlock"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; -import { Label } from "@/components/ui/label"; import Loader from "@/components/ui/loader"; import { useToast } from "@/components/ui/use-toast"; import { searchPlaces } from "@/handlers/api/common.handler"; import { cn } from "@/lib/utils"; import { IPlace } from "@/types/common"; -import clsx from "clsx"; import { Check } from "lucide-react"; import React, { useRef, useState } from "react"; diff --git a/src/components/assets/missing-location/TagMissingLocationDialog/TagMissingLocationSearchLatLong.tsx b/src/components/assets/missing-location/TagMissingLocationDialog/TagMissingLocationSearchLatLong.tsx index d1b75f8..5c2afa1 100644 --- a/src/components/assets/missing-location/TagMissingLocationDialog/TagMissingLocationSearchLatLong.tsx +++ b/src/components/assets/missing-location/TagMissingLocationDialog/TagMissingLocationSearchLatLong.tsx @@ -1,16 +1,11 @@ -import ErrorBlock from "@/components/shared/ErrorBlock"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; -import Loader from "@/components/ui/loader"; import { useToast } from "@/components/ui/use-toast"; -import { searchPlaces } from "@/handlers/api/common.handler"; -import { cn } from "@/lib/utils"; import { IPlace } from "@/types/common"; -import { Check } from "lucide-react"; -import React, { useMemo, useRef, useState } from "react"; +import React, { useMemo, useState } from "react"; interface TagMissingLocationSearchLatLongProps { onSubmit: (place: IPlace) => Promise; diff --git a/src/components/layouts/PageLayout.tsx b/src/components/layouts/PageLayout.tsx index 16a3e52..578e789 100644 --- a/src/components/layouts/PageLayout.tsx +++ b/src/components/layouts/PageLayout.tsx @@ -1,8 +1,6 @@ import React from "react"; import Header from "../shared/Header"; import { cn } from "@/lib/utils"; -import Head from "next/head"; - interface IProps { children: React.ReactNode[] | React.ReactNode; diff --git a/src/components/layouts/RootLayout.tsx b/src/components/layouts/RootLayout.tsx index f5bbbab..5a366a4 100644 --- a/src/components/layouts/RootLayout.tsx +++ b/src/components/layouts/RootLayout.tsx @@ -11,7 +11,6 @@ import { LoginForm } from "../auth/LoginForm"; import { useConfig } from "@/contexts/ConfigContext"; import { Toaster } from "react-hot-toast"; import { useRouter } from "next/router"; -import PageLayout from "./PageLayout"; type RootLayoutProps = { children: ReactNode; diff --git a/src/components/people/PeopleFilters.tsx b/src/components/people/PeopleFilters.tsx index 05aea24..c3ab871 100644 --- a/src/components/people/PeopleFilters.tsx +++ b/src/components/people/PeopleFilters.tsx @@ -16,7 +16,6 @@ import { Input } from "../ui/input"; import { IPersonListFilters } from "@/handlers/api/people.handler"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/select"; import { removeNullOrUndefinedProperties } from "@/helpers/data.helper"; -import { ParsedUrlQueryInput } from "querystring"; export function PeopleFilters() { const router = useRouter(); diff --git a/src/components/people/PersonHideCell.tsx b/src/components/people/PersonHideCell.tsx index 81971d1..f1ffb6c 100644 --- a/src/components/people/PersonHideCell.tsx +++ b/src/components/people/PersonHideCell.tsx @@ -1,11 +1,6 @@ import { IPerson } from "@/types/person"; import React, { useState } from "react"; -import { DatePicker } from "../ui/datepicker"; import { updatePerson } from "@/handlers/api/people.handler"; -import { formatDate } from "@/helpers/date.helper"; -import { Button } from "../ui/button"; -import { Switch } from "../ui/switch"; -import { Label } from "../ui/label"; interface IProps { person: IPerson; diff --git a/src/components/people/PersonItem.tsx b/src/components/people/PersonItem.tsx index 155dde4..d444b10 100644 --- a/src/components/people/PersonItem.tsx +++ b/src/components/people/PersonItem.tsx @@ -6,7 +6,7 @@ import { PersonMergeDropdown } from "./PersonMergeDropdown"; import PersonBirthdayCell from "./PersonBirthdayCell"; import clsx from "clsx"; import Link from "next/link"; -import { ArrowUpRight, Info, Search } from "lucide-react"; +import { ArrowUpRight, Info } from "lucide-react"; import { useConfig } from "@/contexts/ConfigContext"; import { useToast } from "../ui/use-toast"; import { Badge } from "../ui/badge"; diff --git a/src/components/people/info/PersonAlbumList.tsx b/src/components/people/info/PersonAlbumList.tsx index 5d4447e..32d50b6 100644 --- a/src/components/people/info/PersonAlbumList.tsx +++ b/src/components/people/info/PersonAlbumList.tsx @@ -1,6 +1,5 @@ import { ASSET_THUMBNAIL_PATH } from '@/config/routes'; import { useConfig } from '@/contexts/ConfigContext'; -import { ExternalLink } from 'lucide-react'; import Image from 'next/image'; import Link from 'next/link'; import React, { useMemo } from 'react' diff --git a/src/components/shared/AlbumDropdown.tsx b/src/components/shared/AlbumDropdown.tsx index 8ff4f3f..f23e4dc 100644 --- a/src/components/shared/AlbumDropdown.tsx +++ b/src/components/shared/AlbumDropdown.tsx @@ -2,7 +2,6 @@ import { listAlbums } from '@/handlers/api/album.handler'; import { IAlbum } from '@/types/album'; import React, { useEffect, useState } from 'react' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select'; -import { X } from 'lucide-react'; interface IAlbumDropdownProps { albumIds?: string[]; diff --git a/src/components/shared/ErrorBlock.tsx b/src/components/shared/ErrorBlock.tsx index 6cdf5a9..cf6605c 100644 --- a/src/components/shared/ErrorBlock.tsx +++ b/src/components/shared/ErrorBlock.tsx @@ -1,5 +1,3 @@ -import { useConfig } from '@/contexts/ConfigContext'; -import { Link } from 'lucide-react'; import React from 'react' interface ErrorBlockProps { diff --git a/src/components/shared/FloatingBar.tsx b/src/components/shared/FloatingBar.tsx index 73e3aa7..06d1a4c 100644 --- a/src/components/shared/FloatingBar.tsx +++ b/src/components/shared/FloatingBar.tsx @@ -1,4 +1,3 @@ -import { Button } from '@/components/ui/button' import React from 'react' interface FloatingBarProps { diff --git a/src/components/shared/Header.tsx b/src/components/shared/Header.tsx index e8898c7..c9606e8 100644 --- a/src/components/shared/Header.tsx +++ b/src/components/shared/Header.tsx @@ -1,23 +1,7 @@ import React, { useMemo } from "react"; import Link from "next/link"; -import { - Home, - LineChart, - Menu, - Package, - Package2, - ShoppingCart, - Users, -} from "lucide-react"; -import { Badge } from "@/components/ui/badge"; +import { Menu } from "lucide-react"; import { Button } from "@/components/ui/button"; -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, -} from "@/components/ui/card"; import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet"; import Head from "next/head"; import { sidebarNavs } from "@/config/constants/sidebarNavs"; diff --git a/src/components/shared/PeopleList.tsx b/src/components/shared/PeopleList.tsx index f7316a1..3ac016f 100644 --- a/src/components/shared/PeopleList.tsx +++ b/src/components/shared/PeopleList.tsx @@ -2,7 +2,6 @@ import React, { useCallback, useMemo, useState } from 'react' import { IPerson } from '@/types/person'; import { cn } from '@/lib/utils'; import LazyImage from '../ui/lazy-image'; -import { PERSON_THUBNAIL_PATH } from '@/config/routes'; import { Input } from '../ui/input'; interface PeopleListProps { diff --git a/src/components/shared/ShareAssetsTrigger.tsx b/src/components/shared/ShareAssetsTrigger.tsx index d8fc7ab..31e05db 100644 --- a/src/components/shared/ShareAssetsTrigger.tsx +++ b/src/components/shared/ShareAssetsTrigger.tsx @@ -9,7 +9,6 @@ import { Label } from '@radix-ui/react-label'; import { Switch } from '../ui/switch'; import { Select, SelectValue, SelectContent, SelectItem, SelectTrigger } from '../ui/select'; - interface ShareAssetsTriggerProps { filters: ShareLinkFilters buttonProps?: ButtonProps diff --git a/src/components/shared/ThemeSwitcher.tsx b/src/components/shared/ThemeSwitcher.tsx index 1baa853..6db6d89 100644 --- a/src/components/shared/ThemeSwitcher.tsx +++ b/src/components/shared/ThemeSwitcher.tsx @@ -1,5 +1,4 @@ import React from "react"; -import { Button } from "../ui/button"; import { useTheme } from "next-themes"; import { Moon, Sun } from "lucide-react"; import { cn } from "@/lib/utils"; @@ -15,7 +14,7 @@ export default function ThemeSwitcher() {