mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-16 13:40:24 +02:00
add double click play to album detail
- add mediaPlayByIndex - add index property to item list controls args - add overrides to item list controls
This commit is contained in:
@@ -12,10 +12,14 @@ export const ActionsColumn = (props: ItemTableListInnerColumn) => {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
if (row !== undefined) {
|
||||
const item = row as ItemListItem;
|
||||
const rowId = props.internalState.extractRowId(item);
|
||||
const index = rowId ? props.internalState.findItemIndex(rowId) : -1;
|
||||
props.controls.onMore?.({
|
||||
event,
|
||||
index,
|
||||
internalState: props.internalState,
|
||||
item: row as ItemListItem,
|
||||
item,
|
||||
itemType: props.itemType,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,11 +24,15 @@ export const FavoriteColumn = (props: ItemTableListInnerColumn) => {
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
const item = props.data[props.rowIndex] as ItemListItem;
|
||||
const rowId = props.internalState.extractRowId(item);
|
||||
const index = rowId ? props.internalState.findItemIndex(rowId) : -1;
|
||||
props.controls.onFavorite?.({
|
||||
event,
|
||||
favorite: !row,
|
||||
index,
|
||||
internalState: props.internalState,
|
||||
item: props.data[props.rowIndex] as ItemListItem,
|
||||
item,
|
||||
itemType: props.itemType,
|
||||
});
|
||||
}}
|
||||
|
||||
@@ -16,10 +16,14 @@ export const RatingColumn = (props: ItemTableListInnerColumn) => {
|
||||
<Rating
|
||||
className={row ? undefined : 'hover-only-flex'}
|
||||
onChange={(rating) => {
|
||||
const item = props.data[props.rowIndex] as ItemListItem;
|
||||
const rowId = props.internalState.extractRowId(item);
|
||||
const index = rowId ? props.internalState.findItemIndex(rowId) : -1;
|
||||
props.controls.onRating?.({
|
||||
event: null,
|
||||
index,
|
||||
internalState: props.internalState,
|
||||
item: props.data[props.rowIndex] as ItemListItem,
|
||||
item,
|
||||
itemType: props.itemType,
|
||||
rating,
|
||||
});
|
||||
|
||||
@@ -20,7 +20,9 @@ export const RowIndexColumn = (props: ItemTableListInnerColumn) => {
|
||||
const { itemType } = props;
|
||||
|
||||
switch (itemType) {
|
||||
case LibraryItem.PLAYLIST_SONG:
|
||||
case LibraryItem.QUEUE_SONG:
|
||||
case LibraryItem.SONG:
|
||||
return <QueueSongRowIndexColumn {...props} />;
|
||||
default:
|
||||
return <DefaultRowIndexColumn {...props} />;
|
||||
@@ -54,14 +56,18 @@ const DefaultRowIndexColumn = (props: ItemTableListInnerColumn) => {
|
||||
className={clsx(styles.expand, 'hover-only')}
|
||||
icon="arrowDownS"
|
||||
iconProps={{ color: 'muted', size: 'md' }}
|
||||
onClick={(e) =>
|
||||
onClick={(e) => {
|
||||
const item = data[rowIndex] as ItemListItem;
|
||||
const rowId = internalState.extractRowId(item);
|
||||
const index = rowId ? internalState.findItemIndex(rowId) : -1;
|
||||
controls.onExpand?.({
|
||||
event: e,
|
||||
index,
|
||||
internalState,
|
||||
item: data[rowIndex] as ItemListItem,
|
||||
item,
|
||||
itemType,
|
||||
})
|
||||
}
|
||||
});
|
||||
}}
|
||||
size="xs"
|
||||
variant="subtle"
|
||||
/>
|
||||
@@ -78,7 +84,7 @@ const DefaultRowIndexColumn = (props: ItemTableListInnerColumn) => {
|
||||
const QueueSongRowIndexColumn = (props: ItemTableListInnerColumn) => {
|
||||
const status = usePlayerStatus();
|
||||
const song = props.data[props.rowIndex] as QueueSong;
|
||||
const isActive = props.activeRowId === song?._uniqueId;
|
||||
const isActive = props.activeRowId === song?.id || props.activeRowId === song?._uniqueId;
|
||||
|
||||
let adjustedRowIndex =
|
||||
props.adjustedRowIndexMap?.get(props.rowIndex) ??
|
||||
|
||||
@@ -17,7 +17,9 @@ export const TitleColumn = (props: ItemTableListInnerColumn) => {
|
||||
const { itemType } = props;
|
||||
|
||||
switch (itemType) {
|
||||
case LibraryItem.PLAYLIST_SONG:
|
||||
case LibraryItem.QUEUE_SONG:
|
||||
case LibraryItem.SONG:
|
||||
return <QueueSongTitleColumn {...props} />;
|
||||
default:
|
||||
return <DefaultTitleColumn {...props} />;
|
||||
@@ -72,7 +74,7 @@ function QueueSongTitleColumn(props: ItemTableListInnerColumn) {
|
||||
];
|
||||
|
||||
const song = props.data[props.rowIndex] as QueueSong;
|
||||
const isActive = props.activeRowId === song?._uniqueId;
|
||||
const isActive = props.activeRowId === song?.id || props.activeRowId === song?._uniqueId;
|
||||
|
||||
if (typeof row === 'string') {
|
||||
const path = getTitlePath(props.itemType, (props.data[props.rowIndex] as any).id as string);
|
||||
|
||||
@@ -88,7 +88,7 @@ export const QueueSongTitleCombinedColumn = (props: ItemTableListInnerColumn) =>
|
||||
const row: object | undefined = (props.data as (any | undefined)[])[props.rowIndex];
|
||||
|
||||
const song = props.data[props.rowIndex] as QueueSong;
|
||||
const isActive = props.activeRowId === song?._uniqueId;
|
||||
const isActive = props.activeRowId === song?.id || props.activeRowId === song?._uniqueId;
|
||||
|
||||
const artists = useMemo(() => {
|
||||
if (row && 'artists' in row && Array.isArray(row.artists)) {
|
||||
@@ -167,7 +167,9 @@ export const TitleCombinedColumn = (props: ItemTableListInnerColumn) => {
|
||||
const { itemType } = props;
|
||||
|
||||
switch (itemType) {
|
||||
case LibraryItem.PLAYLIST_SONG:
|
||||
case LibraryItem.QUEUE_SONG:
|
||||
case LibraryItem.SONG:
|
||||
return <QueueSongTitleCombinedColumn {...props} />;
|
||||
default:
|
||||
return <DefaultTitleCombinedColumn {...props} />;
|
||||
|
||||
@@ -547,8 +547,11 @@ export const TableColumnTextContainer = (
|
||||
const handleClick = useDoubleClick({
|
||||
onDoubleClick: (event: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (isDataRow && item) {
|
||||
const rowId = props.internalState.extractRowId(item);
|
||||
const index = rowId ? props.internalState.findItemIndex(rowId) : -1;
|
||||
props.controls.onDoubleClick?.({
|
||||
event,
|
||||
index,
|
||||
internalState: props.internalState,
|
||||
item: item as ItemListItem,
|
||||
itemType: props.itemType,
|
||||
@@ -567,8 +570,11 @@ export const TableColumnTextContainer = (
|
||||
}
|
||||
|
||||
if (isDataRow && item && props.enableSelection) {
|
||||
const rowId = props.internalState.extractRowId(item);
|
||||
const index = rowId ? props.internalState.findItemIndex(rowId) : -1;
|
||||
props.controls.onClick?.({
|
||||
event,
|
||||
index,
|
||||
internalState: props.internalState,
|
||||
item: item as ItemListItem,
|
||||
itemType: props.itemType,
|
||||
@@ -580,8 +586,11 @@ export const TableColumnTextContainer = (
|
||||
const handleContextMenu = (event: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (isDataRow && item) {
|
||||
event.preventDefault();
|
||||
const rowId = props.internalState.extractRowId(item);
|
||||
const index = rowId ? props.internalState.findItemIndex(rowId) : -1;
|
||||
props.controls.onMore?.({
|
||||
event,
|
||||
index,
|
||||
internalState: props.internalState,
|
||||
item: item as ItemListItem,
|
||||
itemType: props.itemType,
|
||||
@@ -750,8 +759,11 @@ export const TableColumnContainer = (
|
||||
const handleClick = useDoubleClick({
|
||||
onDoubleClick: (event: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (isDataRow && item) {
|
||||
const rowId = props.internalState.extractRowId(item);
|
||||
const index = rowId ? props.internalState.findItemIndex(rowId) : -1;
|
||||
props.controls.onDoubleClick?.({
|
||||
event,
|
||||
index,
|
||||
internalState: props.internalState,
|
||||
item: item as ItemListItem,
|
||||
itemType: props.itemType,
|
||||
@@ -770,8 +782,11 @@ export const TableColumnContainer = (
|
||||
}
|
||||
|
||||
if (isDataRow && item && props.enableSelection) {
|
||||
const rowId = props.internalState.extractRowId(item);
|
||||
const index = rowId ? props.internalState.findItemIndex(rowId) : -1;
|
||||
props.controls.onClick?.({
|
||||
event,
|
||||
index,
|
||||
internalState: props.internalState,
|
||||
item: item as ItemListItem,
|
||||
itemType: props.itemType,
|
||||
@@ -783,8 +798,11 @@ export const TableColumnContainer = (
|
||||
const handleContextMenu = (event: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (isDataRow && item) {
|
||||
event.preventDefault();
|
||||
const rowId = props.internalState.extractRowId(item);
|
||||
const index = rowId ? props.internalState.findItemIndex(rowId) : -1;
|
||||
props.controls.onMore?.({
|
||||
event,
|
||||
index,
|
||||
internalState: props.internalState,
|
||||
item: item as ItemListItem,
|
||||
itemType: props.itemType,
|
||||
|
||||
@@ -697,6 +697,7 @@ interface ItemTableListProps {
|
||||
onColumnResized?: (columnId: TableColumn, width: number) => void;
|
||||
onRangeChanged?: (range: { startIndex: number; stopIndex: number }) => void;
|
||||
onScrollEnd?: (offset: number, internalState: ItemListStateActions) => void;
|
||||
overrideControls?: Partial<ItemControls>;
|
||||
ref?: Ref<ItemListHandle>;
|
||||
rowHeight?: ((index: number, cellProps: TableItemProps) => number) | number;
|
||||
size?: 'compact' | 'default' | 'large';
|
||||
@@ -729,6 +730,7 @@ export const ItemTableList = ({
|
||||
onColumnResized,
|
||||
onRangeChanged,
|
||||
onScrollEnd,
|
||||
overrideControls,
|
||||
ref,
|
||||
rowHeight,
|
||||
size = 'default',
|
||||
@@ -1759,6 +1761,7 @@ export const ItemTableList = ({
|
||||
const controls = useDefaultItemListControls({
|
||||
onColumnReordered,
|
||||
onColumnResized,
|
||||
overrides: overrideControls,
|
||||
});
|
||||
|
||||
// Create itemProps for sticky header
|
||||
|
||||
Reference in New Issue
Block a user