import { useTranslation } from "react-i18next" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { ScrollArea } from "@/components/ui/scroll-area" import { cn } from "@/lib/utils" import { AlbumSource } from "#/types/cloudAlbum" import { AlbumSourceSwitcher } from "@/components/common/album-source-switcher" import { CloudFeatureHighlights } from "@/components/common/cloud-feature-highlights" import { CloudRefreshButton } from "@/components/common/cloud-refresh-button" import { useCloudAlbumStatsQuery } from "@/queries/picgo-cloud-album-stats" import { useAppStore } from "@/store" import { CloudSidebarSkeleton } from "./cloud-loading" import { NavType, type AlbumProviderFilter, type AlbumPhoto, type NavContext, } from "./utils" export const allPhotosKey = "all" // TODO(v3-post-launch): Restore TagButtonProps when Tags sidebar filter is re-enabled. // type TagButtonProps = { // label: string // active: boolean // onClick: () => void // } type AlbumNavButtonProps = { label: string count?: number | string active: boolean onClick: () => void } type AlbumSidebarProps = { images: AlbumPhoto[] providers: AlbumProviderFilter[] navContext: NavContext albumSource: AlbumSource isCloudAvailable: boolean // TODO(v3-post-launch): Restore tag suggestions input when Tags feature returns. // tagSuggestions: string[] onFilterChange: (next: NavContext) => void onCloudRefresh?: () => Promise | void } // TODO(v3-post-launch): Restore TagButton when Tags sidebar filter is re-enabled. // function TagButton({ label, active, onClick }: TagButtonProps) { // return ( // // ) // } function AlbumNavButton({ label, count, active, onClick, }: AlbumNavButtonProps) { return ( ) } export function AlbumSidebar({ images, providers, navContext, albumSource, isCloudAvailable, // TODO(v3-post-launch): Restore tagSuggestions usage when Tags sidebar filter is re-enabled. // tagSuggestions, onFilterChange, onCloudRefresh, }: AlbumSidebarProps) { const { t } = useTranslation() const isCloud = albumSource === AlbumSource.CLOUD const showCloudNav = isCloud && isCloudAvailable const picBeds = useAppStore.use.picBeds() const cloudStatsQuery = useCloudAlbumStatsQuery({ enabled: showCloudNav }) const cloudStats = cloudStatsQuery.data const cloudStatsError = showCloudNav && cloudStatsQuery.isError const cloudProviderFilters: AlbumProviderFilter[] = (cloudStats?.types ?? []).map((stat) => { const bed = picBeds.find((b) => b.type === stat.type) return { type: stat.type, name: bed?.name ?? stat.type, count: stat.count, } }) const displayProviders = showCloudNav ? cloudProviderFilters : isCloud ? [] : providers const allPhotosCount: number | string = showCloudNav ? (cloudStatsError ? "—" : (cloudStats?.total ?? 0)) : isCloud ? 0 : images.length const isCloudLoading = showCloudNav && cloudStatsQuery.isPending && !cloudStats const showNavList = !isCloud || showCloudNav // TODO(v3-post-launch): Restore collection count aggregation when Collections sidebar section is re-enabled. // const collectionCounts: Record = {} // collections.forEach((collection) => { // collectionCounts[collection] = 0 // }) // images.forEach((image) => { // collectionCounts[image.collection] = // (collectionCounts[image.collection] ?? 0) + 1 // }) // TODO(v3-post-launch): Restore sidebar tag derivation when Tags sidebar section is re-enabled. // const sidebarTags = buildSidebarTags(images, tagSuggestions) return ( ) }