fix: drop selection counts from media action menus #123

Merged
joshuafhiggins merged 1 commits from t3/remove-action-menu-counts into main 2026-11-19 19:57:52 -05:00
2 changed files with 16 additions and 34 deletions

No files matched your search

+10 -21
View File
@@ -77,44 +77,39 @@ const QUEUE_ACTIONS: MediaAction[] = ["play-next", "play-last", "shuffle"]
const MEDIA_ACTION_ITEMS: {
action: MediaAction
label: (
countSuffix: string,
favorited: boolean | undefined,
playlistLabel: string
) => string
label: (favorited: boolean | undefined, playlistLabel: string) => string
image: NonNullable<MenuAction["image"]> & string
destructive?: boolean
}[] = [
{
action: "playlist",
label: (countSuffix, _favorited, playlistLabel) =>
`${playlistLabel}${countSuffix}`,
label: (_favorited, playlistLabel) => playlistLabel,
image: "text.badge.plus",
},
{
action: "download",
label: (countSuffix) => `Download${countSuffix}`,
label: () => "Download",
image: "arrow.down.circle",
},
{
action: "remove-download",
label: (countSuffix) => `Remove Download${countSuffix}`,
label: () => "Remove Download",
image: "xmark.circle",
destructive: true,
},
{
action: "play-next",
label: (countSuffix) => `Play Next${countSuffix}`,
label: () => "Play Next",
image: "text.line.first.and.arrowtriangle.forward",
},
{
action: "play-last",
label: (countSuffix) => `Play Last${countSuffix}`,
label: () => "Play Last",
image: "text.line.last.and.arrowtriangle.forward",
},
{
action: "shuffle",
label: (countSuffix) => `Shuffle${countSuffix}`,
label: () => "Shuffle",
image: "shuffle",
},
{
@@ -134,8 +129,7 @@ const MEDIA_ACTION_ITEMS: {
},
{
action: "favorite",
label: (countSuffix, favorited) =>
`${favorited ? "Unfavorite" : "Favorite"}${countSuffix}`,
label: (favorited) => (favorited ? "Unfavorite" : "Favorite"),
image: "star",
},
{
@@ -206,12 +200,7 @@ function isActionIncluded(
export function buildMediaMenuActions(
config: Omit<MediaMenuConfig, "onAction">
): MenuAction[] {
const {
selectedCount = 1,
favorited,
playlistLabel = "Add to Playlist",
} = config
const countSuffix = selectedCount > 1 ? ` (${selectedCount})` : ""
const { favorited, playlistLabel = "Add to Playlist" } = config
const actions: MenuAction[] = []
@@ -230,7 +219,7 @@ export function buildMediaMenuActions(
actions.push({
id: item.action,
title: item.label(countSuffix, favorited, playlistLabel),
title: item.label(favorited, playlistLabel),
image: item.action === "favorite" && favorited ? "star.fill" : item.image,
...(item.destructive ? { attributes: { destructive: true } } : {}),
})
+6 -13
View File
@@ -74,10 +74,6 @@ export function MediaMenuSeparator() {
)
}
function actionLabel(base: string, selectedCount: number) {
return selectedCount > 1 ? `${base} (${selectedCount})` : base
}
export function MediaContextMenuItems({
selectedCount,
onAction,
@@ -121,7 +117,7 @@ export function MediaContextMenuItems({
className="justify-between"
onClick={() => onAction("playlist")}
>
{actionLabel(playlistLabel, selectedCount)}
{playlistLabel}
<ListPlus />
</MediaMenuItem>
{downloaded !== undefined ? (
@@ -129,10 +125,7 @@ export function MediaContextMenuItems({
className="justify-between"
onClick={() => onAction(downloaded ? "remove-download" : "download")}
>
{actionLabel(
downloaded ? "Remove Download" : "Download",
selectedCount
)}
{downloaded ? "Remove Download" : "Download"}
{downloaded ? <CircleX /> : <ArrowDownToLine />}
</MediaMenuItem>
) : null}
@@ -141,21 +134,21 @@ export function MediaContextMenuItems({
className="justify-between"
onClick={() => onAction("play-next")}
>
{actionLabel("Play Next", selectedCount)}
Play Next
<ListStart />
</MediaMenuItem>
<MediaMenuItem
className="justify-between"
onClick={() => onAction("play-last")}
>
{actionLabel("Play Last", selectedCount)}
Play Last
<ListEnd />
</MediaMenuItem>
<MediaMenuItem
className="justify-between"
onClick={() => onAction("shuffle")}
>
{actionLabel("Shuffle", selectedCount)}
Shuffle
<Shuffle />
</MediaMenuItem>
{stationArtistId ? (
@@ -196,7 +189,7 @@ export function MediaContextMenuItems({
className="justify-between"
onClick={() => onAction("favorite")}
>
{actionLabel(favorited ? "Unfavorite" : "Favorite", selectedCount)}
{favorited ? "Unfavorite" : "Favorite"}
<Star />
</MediaMenuItem>
</>