mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-14 11:17:19 +03:00
Always use httpClient
to call APIs
This commit is contained in:
parent
8383527aab
commit
5f6f74ff2d
@ -1,6 +1,6 @@
|
||||
import React, { useState, useEffect } from 'react'
|
||||
import { useDispatch, useSelector } from 'react-redux'
|
||||
import { fetchUtils, useTranslate } from 'react-admin'
|
||||
import { useTranslate } from 'react-admin'
|
||||
import {
|
||||
Popover,
|
||||
Badge,
|
||||
@ -68,13 +68,12 @@ const ActivityPanel = () => {
|
||||
|
||||
const handleMenuOpen = (event) => setAnchorEl(event.currentTarget)
|
||||
const handleMenuClose = () => setAnchorEl(null)
|
||||
const triggerScan = (full) => () =>
|
||||
fetch(subsonic.url('startScan', null, { fullScan: full }))
|
||||
const triggerScan = (full) => () => subsonic.startScan({ fullScan: full })
|
||||
|
||||
// Get updated status on component mount
|
||||
useEffect(() => {
|
||||
fetchUtils
|
||||
.fetchJson(subsonic.url('getScanStatus'))
|
||||
subsonic
|
||||
.getScanStatus()
|
||||
.then((resp) => resp.json['subsonic-response'])
|
||||
.then((data) => {
|
||||
if (data.status === 'ok') {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { fetchUtils } from 'react-admin'
|
||||
import { baseUrl } from '../utils'
|
||||
import { httpClient } from '../dataProvider'
|
||||
|
||||
const url = (command, id, options) => {
|
||||
const params = new URLSearchParams()
|
||||
@ -19,36 +19,40 @@ const url = (command, id, options) => {
|
||||
params.append(k, options[k])
|
||||
})
|
||||
}
|
||||
const url = `/rest/${command}?${params.toString()}`
|
||||
return baseUrl(url)
|
||||
return `/rest/${command}?${params.toString()}`
|
||||
}
|
||||
|
||||
const scrobble = (id, submit) =>
|
||||
fetchUtils.fetchJson(url('scrobble', id, { submission: submit }))
|
||||
httpClient(url('scrobble', id, { submission: submit }))
|
||||
|
||||
const star = (id) => fetchUtils.fetchJson(url('star', id))
|
||||
const star = (id) => httpClient(url('star', id))
|
||||
|
||||
const unstar = (id) => fetchUtils.fetchJson(url('unstar', id))
|
||||
const unstar = (id) => httpClient(url('unstar', id))
|
||||
|
||||
const download = (id) => (window.location.href = url('download', id))
|
||||
const setRating = (id, rating) => httpClient(url('setRating', id, { rating }))
|
||||
|
||||
const download = (id) => (window.location.href = baseUrl(url('download', id)))
|
||||
|
||||
const startScan = (options) => httpClient(url('startScan', null, options))
|
||||
|
||||
const getScanStatus = () => httpClient(url('getScanStatus'))
|
||||
|
||||
const getCoverArtUrl = (record, size) => {
|
||||
const options = {
|
||||
...(record.updatedAt && { _: record.updatedAt }),
|
||||
...(size && { size }),
|
||||
}
|
||||
return url('getCoverArt', record.coverArtId || 'not_found', options)
|
||||
return baseUrl(url('getCoverArt', record.coverArtId || 'not_found', options))
|
||||
}
|
||||
|
||||
const setRating = (id, rating) =>
|
||||
fetchUtils.fetchJson(url('setRating', id, { rating }))
|
||||
|
||||
export default {
|
||||
url,
|
||||
getCoverArtUrl,
|
||||
scrobble,
|
||||
download,
|
||||
star,
|
||||
unstar,
|
||||
setRating,
|
||||
startScan,
|
||||
getScanStatus,
|
||||
getCoverArtUrl,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user