mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-18 21:07:44 +03:00
fix(ui): don't hide Last.fm scrobble switch (#3561)
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
6c11649b06
commit
2d8507cfd7
@ -65,7 +65,9 @@ func (s *Router) routes() http.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Router) getLinkStatus(w http.ResponseWriter, r *http.Request) {
|
func (s *Router) getLinkStatus(w http.ResponseWriter, r *http.Request) {
|
||||||
resp := map[string]interface{}{}
|
resp := map[string]interface{}{
|
||||||
|
"apiKey": s.apiKey,
|
||||||
|
}
|
||||||
u, _ := request.UserFrom(r.Context())
|
u, _ := request.UserFrom(r.Context())
|
||||||
key, err := s.sessionKeys.Get(r.Context(), u.ID)
|
key, err := s.sessionKeys.Get(r.Context(), u.ID)
|
||||||
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
||||||
|
@ -389,6 +389,7 @@
|
|||||||
"language": "Língua",
|
"language": "Língua",
|
||||||
"defaultView": "Tela inicial",
|
"defaultView": "Tela inicial",
|
||||||
"desktop_notifications": "Notificações",
|
"desktop_notifications": "Notificações",
|
||||||
|
"lastfmNotConfigured": "A API-Key do Last.fm não está configurada",
|
||||||
"lastfmScrobbling": "Enviar scrobbles para Last.fm",
|
"lastfmScrobbling": "Enviar scrobbles para Last.fm",
|
||||||
"listenBrainzScrobbling": "Enviar scrobbles para ListenBrainz",
|
"listenBrainzScrobbling": "Enviar scrobbles para ListenBrainz",
|
||||||
"replaygain": "Modo ReplayGain",
|
"replaygain": "Modo ReplayGain",
|
||||||
|
@ -78,9 +78,6 @@ func buildAuthPayload(user *model.User) map[string]interface{} {
|
|||||||
if conf.Server.EnableGravatar && user.Email != "" {
|
if conf.Server.EnableGravatar && user.Email != "" {
|
||||||
payload["avatar"] = gravatar.Url(user.Email, 50)
|
payload["avatar"] = gravatar.Url(user.Email, 50)
|
||||||
}
|
}
|
||||||
if conf.Server.LastFM.Enabled {
|
|
||||||
payload["lastFMApiKey"] = conf.Server.LastFM.ApiKey
|
|
||||||
}
|
|
||||||
|
|
||||||
bytes := make([]byte, 3)
|
bytes := make([]byte, 3)
|
||||||
_, err := rand.Read(bytes)
|
_, err := rand.Read(bytes)
|
||||||
|
@ -22,7 +22,6 @@ function storeAuthenticationInfo(authInfo) {
|
|||||||
localStorage.setItem('role', authInfo.isAdmin ? 'admin' : 'regular')
|
localStorage.setItem('role', authInfo.isAdmin ? 'admin' : 'regular')
|
||||||
localStorage.setItem('subsonic-salt', authInfo.subsonicSalt)
|
localStorage.setItem('subsonic-salt', authInfo.subsonicSalt)
|
||||||
localStorage.setItem('subsonic-token', authInfo.subsonicToken)
|
localStorage.setItem('subsonic-token', authInfo.subsonicToken)
|
||||||
localStorage.setItem('lastfm-apikey', authInfo.lastFMApiKey)
|
|
||||||
localStorage.setItem('is-authenticated', 'true')
|
localStorage.setItem('is-authenticated', 'true')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +103,6 @@ const removeItems = () => {
|
|||||||
localStorage.removeItem('role')
|
localStorage.removeItem('role')
|
||||||
localStorage.removeItem('subsonic-salt')
|
localStorage.removeItem('subsonic-salt')
|
||||||
localStorage.removeItem('subsonic-token')
|
localStorage.removeItem('subsonic-token')
|
||||||
localStorage.removeItem('lastfm-apikey')
|
|
||||||
localStorage.removeItem('is-authenticated')
|
localStorage.removeItem('is-authenticated')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,6 +391,7 @@
|
|||||||
"language": "Language",
|
"language": "Language",
|
||||||
"defaultView": "Default View",
|
"defaultView": "Default View",
|
||||||
"desktop_notifications": "Desktop Notifications",
|
"desktop_notifications": "Desktop Notifications",
|
||||||
|
"lastfmNotConfigured": "Last.fm API-Key is not configured",
|
||||||
"lastfmScrobbling": "Scrobble to Last.fm",
|
"lastfmScrobbling": "Scrobble to Last.fm",
|
||||||
"listenBrainzScrobbling": "Scrobble to ListenBrainz",
|
"listenBrainzScrobbling": "Scrobble to ListenBrainz",
|
||||||
"replaygain": "ReplayGain Mode",
|
"replaygain": "ReplayGain Mode",
|
||||||
|
@ -5,13 +5,14 @@ import {
|
|||||||
FormControlLabel,
|
FormControlLabel,
|
||||||
LinearProgress,
|
LinearProgress,
|
||||||
Switch,
|
Switch,
|
||||||
|
Tooltip,
|
||||||
} from '@material-ui/core'
|
} from '@material-ui/core'
|
||||||
import { useInterval } from '../common'
|
import { useInterval } from '../common'
|
||||||
import { baseUrl, openInNewTab } from '../utils'
|
import { baseUrl, openInNewTab } from '../utils'
|
||||||
import { httpClient } from '../dataProvider'
|
import { httpClient } from '../dataProvider'
|
||||||
|
|
||||||
const Progress = (props) => {
|
const Progress = (props) => {
|
||||||
const { setLinked, setCheckingLink } = props
|
const { setLinked, setCheckingLink, apiKey } = props
|
||||||
const notify = useNotify()
|
const notify = useNotify()
|
||||||
let linkCheckDelay = 2000
|
let linkCheckDelay = 2000
|
||||||
let linkChecks = 30
|
let linkChecks = 30
|
||||||
@ -23,11 +24,9 @@ const Progress = (props) => {
|
|||||||
)
|
)
|
||||||
const callbackUrl = `${window.location.origin}${callbackEndpoint}`
|
const callbackUrl = `${window.location.origin}${callbackEndpoint}`
|
||||||
openedTab.current = openInNewTab(
|
openedTab.current = openInNewTab(
|
||||||
`https://www.last.fm/api/auth/?api_key=${localStorage.getItem(
|
`https://www.last.fm/api/auth/?api_key=${apiKey}&cb=${callbackUrl}`,
|
||||||
'lastfm-apikey',
|
|
||||||
)}&cb=${callbackUrl}`,
|
|
||||||
)
|
)
|
||||||
}, [])
|
}, [apiKey])
|
||||||
|
|
||||||
const endChecking = (success) => {
|
const endChecking = (success) => {
|
||||||
linkCheckDelay = null
|
linkCheckDelay = null
|
||||||
@ -75,6 +74,18 @@ export const LastfmScrobbleToggle = (props) => {
|
|||||||
const translate = useTranslate()
|
const translate = useTranslate()
|
||||||
const [linked, setLinked] = useState(null)
|
const [linked, setLinked] = useState(null)
|
||||||
const [checkingLink, setCheckingLink] = useState(false)
|
const [checkingLink, setCheckingLink] = useState(false)
|
||||||
|
const [apiKey, setApiKey] = useState(false)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
httpClient('/api/lastfm/link')
|
||||||
|
.then((response) => {
|
||||||
|
setLinked(response.json.status === true)
|
||||||
|
setApiKey(response.json.apiKey)
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
setLinked(false)
|
||||||
|
})
|
||||||
|
}, [setLinked, setApiKey])
|
||||||
|
|
||||||
const toggleScrobble = () => {
|
const toggleScrobble = () => {
|
||||||
if (!linked) {
|
if (!linked) {
|
||||||
@ -89,18 +100,9 @@ export const LastfmScrobbleToggle = (props) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
httpClient('/api/lastfm/link')
|
|
||||||
.then((response) => {
|
|
||||||
setLinked(response.json.status === true)
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
setLinked(false)
|
|
||||||
})
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormControl>
|
<FormControl>
|
||||||
|
{apiKey ? (
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
control={
|
control={
|
||||||
<Switch
|
<Switch
|
||||||
@ -115,8 +117,23 @@ export const LastfmScrobbleToggle = (props) => {
|
|||||||
<span>{translate('menu.personal.options.lastfmScrobbling')}</span>
|
<span>{translate('menu.personal.options.lastfmScrobbling')}</span>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
) : (
|
||||||
|
<Tooltip title={translate('menu.personal.options.lastfmNotConfigured')}>
|
||||||
|
<FormControlLabel
|
||||||
|
disabled={true}
|
||||||
|
control={<Switch id={'lastfm'} color="primary" />}
|
||||||
|
label={
|
||||||
|
<span>{translate('menu.personal.options.lastfmScrobbling')}</span>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
{checkingLink && (
|
{checkingLink && (
|
||||||
<Progress setLinked={setLinked} setCheckingLink={setCheckingLink} />
|
<Progress
|
||||||
|
setLinked={setLinked}
|
||||||
|
setCheckingLink={setCheckingLink}
|
||||||
|
apiKey={apiKey}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</FormControl>
|
</FormControl>
|
||||||
)
|
)
|
||||||
|
@ -27,9 +27,7 @@ const Personal = () => {
|
|||||||
<SelectDefaultView />
|
<SelectDefaultView />
|
||||||
{config.enableReplayGain && <ReplayGainToggle />}
|
{config.enableReplayGain && <ReplayGainToggle />}
|
||||||
<NotificationsToggle />
|
<NotificationsToggle />
|
||||||
{config.lastFMEnabled && localStorage.getItem('lastfm-apikey') && (
|
{config.lastFMEnabled && <LastfmScrobbleToggle />}
|
||||||
<LastfmScrobbleToggle />
|
|
||||||
)}
|
|
||||||
{config.listenBrainzEnabled && <ListenBrainzScrobbleToggle />}
|
{config.listenBrainzEnabled && <ListenBrainzScrobbleToggle />}
|
||||||
</SimpleForm>
|
</SimpleForm>
|
||||||
</Card>
|
</Card>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user