- Added AutoTaggingSettings component for configuring auto-tagging preferences. - Integrated localStorage for saving user preferences and options. - Developed useAutoTagging hook for fetching and applying metadata from MusicBrainz. - Created MusicBrainz API client for searching and retrieving music metadata. - Enhanced metadata structure with additional fields for tracks and albums. - Implemented rate-limiting for MusicBrainz API requests. - Added UI components for user interaction and feedback during the tagging process.
74 lines
1.9 KiB
TypeScript
74 lines
1.9 KiB
TypeScript
'use client';
|
|
|
|
import React, { useState } from 'react';
|
|
import {
|
|
ContextMenu,
|
|
ContextMenuContent,
|
|
ContextMenuItem,
|
|
ContextMenuSeparator,
|
|
ContextMenuTrigger,
|
|
} from "@/components/ui/context-menu";
|
|
import { MusicIcon, TagIcon, InfoIcon } from 'lucide-react';
|
|
import { AutoTaggingDialog } from './AutoTaggingDialog';
|
|
|
|
interface AutoTagContextMenuProps {
|
|
children: React.ReactNode;
|
|
mode: 'track' | 'album' | 'artist';
|
|
itemId: string;
|
|
itemName: string;
|
|
artistName?: string;
|
|
}
|
|
|
|
export function AutoTagContextMenu({
|
|
children,
|
|
mode,
|
|
itemId,
|
|
itemName,
|
|
artistName
|
|
}: AutoTagContextMenuProps) {
|
|
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
|
|
|
return (
|
|
<>
|
|
<ContextMenu>
|
|
<ContextMenuTrigger asChild>
|
|
{children}
|
|
</ContextMenuTrigger>
|
|
<ContextMenuContent className="w-56">
|
|
<ContextMenuItem
|
|
onClick={() => setIsDialogOpen(true)}
|
|
className="cursor-pointer"
|
|
>
|
|
<TagIcon className="mr-2 h-4 w-4" />
|
|
Auto-Tag {mode === 'track' ? 'Track' : mode === 'album' ? 'Album' : 'Artist'}
|
|
</ContextMenuItem>
|
|
{mode === 'track' && (
|
|
<>
|
|
<ContextMenuSeparator />
|
|
<ContextMenuItem className="cursor-pointer">
|
|
<InfoIcon className="mr-2 h-4 w-4" />
|
|
View Track Details
|
|
</ContextMenuItem>
|
|
<ContextMenuItem className="cursor-pointer">
|
|
<MusicIcon className="mr-2 h-4 w-4" />
|
|
Edit Track Metadata
|
|
</ContextMenuItem>
|
|
</>
|
|
)}
|
|
</ContextMenuContent>
|
|
</ContextMenu>
|
|
|
|
<AutoTaggingDialog
|
|
isOpen={isDialogOpen}
|
|
onClose={() => setIsDialogOpen(false)}
|
|
mode={mode}
|
|
itemId={itemId}
|
|
itemName={itemName}
|
|
artistName={artistName}
|
|
/>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default AutoTagContextMenu;
|