-
Notifications
You must be signed in to change notification settings - Fork 33
Add collections list route and support playlist/track collection items #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,28 +1,44 @@ | ||||||
| import { Option } from "../interfaces"; | ||||||
| import { Option, Playlist, Collection } from '@/interfaces' | ||||||
| import { addOrRemoveItemFromCollection } from '@/requests/collections' | ||||||
| import { Routes, router } from '@/router' | ||||||
| import useCollection from '@/stores/pages/collections' | ||||||
| import { DeleteIcon, PlusIcon } from '@/icons' | ||||||
| import { getAddToCollectionOptions } from './utils' | ||||||
|
|
||||||
| export default async () => { | ||||||
| const deletePlaylist: Option = { | ||||||
| label: "Delete playlist", | ||||||
| critical: true, | ||||||
| action: () => { | ||||||
| console.log("delete playlist"); | ||||||
| }, | ||||||
| }; | ||||||
| export default async (playlist: Playlist): Promise<Option[]> => { | ||||||
| const addToCollectionAction = (collection: Collection) => { | ||||||
| addOrRemoveItemFromCollection(collection.id, playlist, 'playlist', 'add') | ||||||
| } | ||||||
|
|
||||||
| const playNext: Option = { | ||||||
| label: "Play next", | ||||||
| action: () => { | ||||||
| console.log("play next"); | ||||||
| }, | ||||||
| }; | ||||||
| const add_to_collection: Option = { | ||||||
| label: 'Add to Collection', | ||||||
| children: () => | ||||||
| getAddToCollectionOptions(addToCollectionAction, { | ||||||
| collection: null, | ||||||
| hash: playlist.id.toString(), | ||||||
| type: 'playlist', | ||||||
| extra: {}, | ||||||
| }), | ||||||
| icon: PlusIcon, | ||||||
| } | ||||||
|
|
||||||
| const addToQueue: Option = { | ||||||
| label: "Add to queue", | ||||||
| action: () => { | ||||||
| console.log("add to queue"); | ||||||
| }, | ||||||
| }; | ||||||
| const remove_from_collection: Option = { | ||||||
| label: 'Remove item', | ||||||
| action: async () => { | ||||||
| const success = await addOrRemoveItemFromCollection( | ||||||
| parseInt(router.currentRoute.value.params.collection as string), | ||||||
| playlist, | ||||||
| 'playlist', | ||||||
| 'remove' | ||||||
| ) | ||||||
|
|
||||||
| if (success) { | ||||||
| useCollection().removeLocalItem(playlist as any, 'playlist' as any) | ||||||
|
||||||
| useCollection().removeLocalItem(playlist as any, 'playlist' as any) | |
| useCollection().removeLocalItem(playlist, 'playlist') |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,16 +1,18 @@ | ||||||
| import { router } from '@/router' | ||||||
| import { Artist, Playlist, Track } from '@/interfaces' | ||||||
| import { Artist, Collection, Playlist, Track } from '@/interfaces' | ||||||
| import { router as Router, Routes } from '@/router' | ||||||
|
|
||||||
| import { Option } from '@/interfaces' | ||||||
| import { openInFiles } from '@/requests/folders' | ||||||
| import { addTracksToPlaylist, removeTracks } from '@/requests/playlists' | ||||||
| import { addOrRemoveItemFromCollection } from '@/requests/collections' | ||||||
|
|
||||||
| import { AddToQueueIcon, AlbumIcon, ArtistIcon, DeleteIcon, FolderIcon, PlayNextIcon, PlusIcon } from '@/icons' | ||||||
| import usePlaylistStore from '@/stores/pages/playlist' | ||||||
| import useCollection from '@/stores/pages/collections' | ||||||
| import useQueueStore from '@/stores/queue' | ||||||
| import useTracklist from '@/stores/queue/tracklist' | ||||||
| import { getAddToPlaylistOptions, get_find_on_social } from './utils' | ||||||
| import { getAddToCollectionOptions, getAddToPlaylistOptions, get_find_on_social } from './utils' | ||||||
|
|
||||||
| /** | ||||||
| * Returns a list of context menu items for a track. | ||||||
|
|
@@ -69,6 +71,40 @@ export default async (track: Track): Promise<Option[]> => { | |||||
| icon: PlusIcon, | ||||||
| } | ||||||
|
|
||||||
| const addToCollectionAction = (collection: Collection) => { | ||||||
| addOrRemoveItemFromCollection(collection.id, track, 'track', 'add') | ||||||
| } | ||||||
|
|
||||||
| const add_to_collection: Option = { | ||||||
| label: 'Add to Collection', | ||||||
| children: () => | ||||||
| getAddToCollectionOptions(addToCollectionAction, { | ||||||
| collection: null, | ||||||
| hash: track.trackhash, | ||||||
| type: 'track', | ||||||
| extra: {}, | ||||||
| }), | ||||||
| icon: PlusIcon, | ||||||
| } | ||||||
|
|
||||||
| const remove_from_collection: Option = { | ||||||
| label: 'Remove item', | ||||||
| action: async () => { | ||||||
| const success = await addOrRemoveItemFromCollection( | ||||||
| parseInt(route.params.collection as string), | ||||||
| track, | ||||||
| 'track', | ||||||
| 'remove' | ||||||
| ) | ||||||
|
|
||||||
| if (success) { | ||||||
| useCollection().removeLocalItem(track as any, 'track' as any) | ||||||
|
||||||
| useCollection().removeLocalItem(track as any, 'track' as any) | |
| useCollection().removeLocalItem(track, 'track') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
collectionsis appended as the lastmenusentry. InLeftSidebar/NavButtons.vuethe CSS hides.circular.nav-item:last-childon phones, so this will likely hide the new Collections nav item instead of the Settings item. Reordermenus(or adjust the selector) so the intended item is hidden on mobile.