Implement Navidrome sharing (#575)

* add share item feature

* take care of (mostly) everything

* bugfixes

* allow clicking on notification to open url

* readd the missing modal after router migration

* remove unnecessary extension

---------

Co-authored-by: Kendall Garner <17521368+kgarner7@users.noreply.github.com>
This commit is contained in:
Benjamin 2024-04-21 22:03:22 -05:00 committed by GitHub
parent 0d03b66fe5
commit cb2597d2c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 303 additions and 4 deletions

View file

@ -8,6 +8,7 @@ import type {
AlbumArtistDetailArgs,
AlbumArtistListArgs,
SetRatingArgs,
ShareItemArgs,
GenreListArgs,
CreatePlaylistArgs,
DeletePlaylistArgs,
@ -55,6 +56,7 @@ import type {
SimilarSongsArgs,
Song,
ServerType,
ShareItemResponse,
} from '/@/renderer/api/types';
import { DeletePlaylistResponse, RandomSongListArgs } from './types';
import { ndController } from '/@/renderer/api/navidrome/navidrome-controller';
@ -102,6 +104,7 @@ export type ControllerEndpoint = Partial<{
scrobble: (args: ScrobbleArgs) => Promise<ScrobbleResponse>;
search: (args: SearchArgs) => Promise<SearchResponse>;
setRating: (args: SetRatingArgs) => Promise<RatingResponse>;
shareItem: (args: ShareItemArgs) => Promise<ShareItemResponse>;
updatePlaylist: (args: UpdatePlaylistArgs) => Promise<UpdatePlaylistResponse>;
}>;
@ -149,6 +152,7 @@ const endpoints: ApiController = {
scrobble: jfController.scrobble,
search: jfController.search,
setRating: undefined,
shareItem: undefined,
updatePlaylist: jfController.updatePlaylist,
},
navidrome: {
@ -188,6 +192,7 @@ const endpoints: ApiController = {
scrobble: ssController.scrobble,
search: ssController.search3,
setRating: ssController.setRating,
shareItem: ndController.shareItem,
updatePlaylist: ndController.updatePlaylist,
},
subsonic: {
@ -223,6 +228,7 @@ const endpoints: ApiController = {
scrobble: ssController.scrobble,
search: ssController.search3,
setRating: undefined,
shareItem: undefined,
updatePlaylist: undefined,
},
};
@ -457,6 +463,15 @@ const updateRating = async (args: SetRatingArgs) => {
)?.(args);
};
const shareItem = async (args: ShareItemArgs) => {
return (
apiController(
'shareItem',
args.apiClientProps.server?.type,
) as ControllerEndpoint['shareItem']
)?.(args);
};
const getTopSongList = async (args: TopSongListArgs) => {
return (
apiController(
@ -555,6 +570,7 @@ export const controller = {
removeFromPlaylist,
scrobble,
search,
shareItem,
updatePlaylist,
updateRating,
};