mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
refactor(context-menu): H.1–H.12 — extract submenus + 5 type-branch components + hooks (Phase H start) (#662)
* refactor(context-menu): H.1 — extract helpers + constants * refactor(context-menu): H.2 — extract AddToPlaylistSubmenu component * refactor(context-menu): H.3 — extract AlbumToPlaylistSubmenu + ArtistToPlaylistSubmenu * refactor(context-menu): H.4 — extract MultiAlbumToPlaylistSubmenu * refactor(context-menu): H.5 — extract MultiArtistToPlaylistSubmenu * refactor(context-menu): H.6 — extract SinglePlaylist + MultiPlaylist submenus * refactor(context-menu): H.7 — extract startRadio/startInstantMix/downloadAlbum/copyShareLink actions * refactor(context-menu): H.8 — extract useContextMenuKeyboardNav hook * refactor(context-menu): H.9 — extract useContextMenuRating hook * refactor(context-menu): H.10 — extract ContextMenuItems (all 9 type branches) * refactor(context-menu): H.11 — split ContextMenuItems into 5 type-branch files ContextMenuItems.tsx (800 LOC) was just a moved 400-LOC-cap violation. Now ContextMenuItems is a 30-LOC switch that dispatches to: - SongContextItems (song + album-song + favorite-song) - QueueItemContextItems (queue-item) - AlbumContextItems (album + multi-album) - ArtistContextItems (artist + multi-artist) - PlaylistContextItems (playlist + multi-playlist) All five branch files are now under 330 LOC; ContextMenu.tsx itself stays at 194 LOC. Shared Props interface lives in contextMenuItemTypes.ts. * refactor(context-menu): H.12 — strip unused imports from branch components
This commit is contained in:
committed by
GitHub
parent
c2b75817c4
commit
ef5eda263d
@@ -0,0 +1,30 @@
|
||||
import React from 'react';
|
||||
import type { ContextMenuItemsProps } from './contextMenuItemTypes';
|
||||
import SongContextItems from './SongContextItems';
|
||||
import QueueItemContextItems from './QueueItemContextItems';
|
||||
import AlbumContextItems from './AlbumContextItems';
|
||||
import ArtistContextItems from './ArtistContextItems';
|
||||
import PlaylistContextItems from './PlaylistContextItems';
|
||||
|
||||
export default function ContextMenuItems(props: ContextMenuItemsProps) {
|
||||
const { type } = props;
|
||||
switch (type) {
|
||||
case 'song':
|
||||
case 'album-song':
|
||||
case 'favorite-song':
|
||||
return <SongContextItems {...props} />;
|
||||
case 'queue-item':
|
||||
return <QueueItemContextItems {...props} />;
|
||||
case 'album':
|
||||
case 'multi-album':
|
||||
return <AlbumContextItems {...props} />;
|
||||
case 'artist':
|
||||
case 'multi-artist':
|
||||
return <ArtistContextItems {...props} />;
|
||||
case 'playlist':
|
||||
case 'multi-playlist':
|
||||
return <PlaylistContextItems {...props} />;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user