Refactored the current ⭐️/Star feature to ❤️/Love/Favourite feature. (#908)
* Added setRating feature to AlbumListView * Refactored the iconography from ⭐ to ❤️ * Refactored the current component from StarButton to LoveButton * Refactored all translations from Starred to Loved, and all props from showStar to showLove * Refactored useToggleStar hook to useToggleLove * rebased repository from master and removed stray commmits * Refactored handler name from TOGGLE_STAR to TOGGLE_LOVE in PlayerToolbar.js * Change "starred" translation to "Favorite" Co-authored-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -2,25 +2,25 @@ import React, { useCallback } from 'react'
|
||||
import { useLocation } from 'react-router-dom'
|
||||
import { useGetOne } from 'react-admin'
|
||||
import { GlobalHotKeys } from 'react-hotkeys'
|
||||
import { StarButton, useToggleStar } from '../common'
|
||||
import { LoveButton, useToggleLove } from '../common'
|
||||
import { keyMap } from '../hotkeys'
|
||||
|
||||
const Placeholder = () => <StarButton disabled={true} resource={'song'} />
|
||||
const Placeholder = () => <LoveButton disabled={true} resource={'song'} />
|
||||
|
||||
const Toolbar = ({ id }) => {
|
||||
const location = useLocation()
|
||||
const resource = location.pathname.startsWith('/song') ? 'song' : 'albumSong'
|
||||
const { data, loading } = useGetOne(resource, id)
|
||||
const [toggleStar, toggling] = useToggleStar(resource, data)
|
||||
const [toggleLove, toggling] = useToggleLove(resource, data)
|
||||
|
||||
const handlers = {
|
||||
TOGGLE_STAR: useCallback(() => toggleStar(), [toggleStar]),
|
||||
TOGGLE_LOVE: useCallback(() => toggleLove(), [toggleLove]),
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<GlobalHotKeys keyMap={keyMap} handlers={handlers} allowChanges />
|
||||
<StarButton
|
||||
<LoveButton
|
||||
record={data}
|
||||
resource={resource}
|
||||
disabled={loading || toggling}
|
||||
|
||||
Reference in New Issue
Block a user