mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-18 07:30:29 +00:00
The Refresh Metadata action was only reachable from the Album and Artist context menus, so it could not be triggered from AlbumShow or ArtistShow. This adds an icon-only button, with a tooltip, to the action toolbar on both detail pages. Like the menu entry, it is only rendered for admins. The button is built on react-admin's Button rather than a plain IconButton: the surrounding toolbars use the former, so the theme colour and the icon-only swap at the xs breakpoint are inherited instead of restated. The dataProvider call and its two notifications move into a new useRefreshMetadata hook, which ContextMenus now shares, keeping a single copy of that logic.
17 lines
463 B
JavaScript
17 lines
463 B
JavaScript
import { useCallback } from 'react'
|
|
import { useDataProvider, useNotify } from 'react-admin'
|
|
|
|
export const useRefreshMetadata = () => {
|
|
const dataProvider = useDataProvider()
|
|
const notify = useNotify()
|
|
|
|
return useCallback(
|
|
(resource, id) =>
|
|
dataProvider
|
|
.refreshMetadata(resource, id)
|
|
.then(() => notify('message.metadataRefreshStarted'))
|
|
.catch(() => notify('ra.page.error', 'warning')),
|
|
[dataProvider, notify],
|
|
)
|
|
}
|