|
|
|
@ -6,6 +6,7 @@ import { newWindowReducer, WindowType } from '../windows/Windows'; |
|
|
|
|
import PersonIcon from '@material-ui/icons/Person'; |
|
|
|
|
import AlbumIcon from '@material-ui/icons/Album'; |
|
|
|
|
import AudiotrackIcon from '@material-ui/icons/Audiotrack'; |
|
|
|
|
import LocalOfferIcon from '@material-ui/icons/LocalOffer'; |
|
|
|
|
|
|
|
|
|
export interface SongGetters { |
|
|
|
|
getTitle: (song: any) => string, |
|
|
|
@ -15,6 +16,7 @@ export interface SongGetters { |
|
|
|
|
getAlbumNames: (song: any) => string[], |
|
|
|
|
getAlbumIds: (song: any) => number[], |
|
|
|
|
getTagNames: (song: any) => string[][], // Each tag is represented as a series of strings.
|
|
|
|
|
getTagIds: (song: any) => number[][], // Each tag is represented as a series of ids.
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export interface IProps { |
|
|
|
@ -55,13 +57,7 @@ export function SongTable(props: IProps) { |
|
|
|
|
const mainAlbumName = albumNames[0]; |
|
|
|
|
const mainAlbumId = props.songGetters.getAlbumIds(song)[0]; |
|
|
|
|
const songId = props.songGetters.getId(song); |
|
|
|
|
const tags = props.songGetters.getTagNames(song).map((tag: string[]) => { |
|
|
|
|
return <Box ml={0.5} mr={0.5}> |
|
|
|
|
<Chip size="small" label={stringifyList(tag, undefined, (idx: number, e: string) => { |
|
|
|
|
return (idx === 0) ? e : " / " + e; |
|
|
|
|
})} /> |
|
|
|
|
</Box> |
|
|
|
|
}); |
|
|
|
|
const tagIds = props.songGetters.getTagIds(song); |
|
|
|
|
|
|
|
|
|
const onClickArtist = () => { |
|
|
|
|
props.mainDispatch({ |
|
|
|
@ -102,6 +98,31 @@ export function SongTable(props: IProps) { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const onClickTag = (id: number, name: string) => { |
|
|
|
|
props.mainDispatch({ |
|
|
|
|
type: MainWindowStateActions.AddTab, |
|
|
|
|
tabState: { |
|
|
|
|
tabLabel: <><LocalOfferIcon />{name}</>, |
|
|
|
|
tagId: id, |
|
|
|
|
metadata: null, |
|
|
|
|
}, |
|
|
|
|
tabReducer: newWindowReducer[WindowType.Tag], |
|
|
|
|
tabType: WindowType.Tag, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const tags = props.songGetters.getTagNames(song).map((tag: string[], i: number) => { |
|
|
|
|
const fullTag = stringifyList(tag, undefined, (idx: number, e: string) => { |
|
|
|
|
return (idx === 0) ? e : " / " + e; |
|
|
|
|
}) |
|
|
|
|
return <Box ml={0.5} mr={0.5}> |
|
|
|
|
<Chip size="small" |
|
|
|
|
label={fullTag} |
|
|
|
|
onClick={() => onClickTag(tagIds[i][tagIds[i].length-1], fullTag)} |
|
|
|
|
/> |
|
|
|
|
</Box> |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const TextCell = (props: any) => { |
|
|
|
|
const classes = makeStyles({ |
|
|
|
|
button: { |
|
|
|
|