|
1 | 1 | <script lang="ts"> |
| 2 | + import type { PlaylistDataShort } from "../../../../../../main/types/playlistDataShort"; |
2 | 3 | import type { SongDataShort } from "../../../../../../main/types/songData"; |
3 | 4 | import { changePageTo } from "../../../state/sharedState.svelte"; |
4 | 5 | import ArtistEntry from "./songEntry/ArtistEntry.svelte"; |
|
15 | 16 | identifier = "", |
16 | 17 | source = "", |
17 | 18 | index = 0, |
| 19 | + playlist /* PlaylistDataShort */ = null, |
18 | 20 | queue = false, |
19 | 21 | songs = [], |
20 | 22 | } = $props(); |
|
125 | 127 | closeMenu(); |
126 | 128 | } |
127 | 129 |
|
| 130 | + function removeFromPlaylist() { |
| 131 | + const songInfo: SongDataShort = { |
| 132 | + title: $state.snapshot(title), |
| 133 | + artistString: $state.snapshot(artistString), |
| 134 | + artists: $state.snapshot(artistList), |
| 135 | + album: $state.snapshot(album), |
| 136 | + identifier: $state.snapshot(identifier), |
| 137 | + source: $state.snapshot(source), |
| 138 | + duration: $state.snapshot(duration), |
| 139 | + index: |
| 140 | + $state.snapshot(index) - |
| 141 | + 1 /* index for playlist is 0 based, while here it's 1 based for the user. */, |
| 142 | + }; |
| 143 | + console.log("removing index " + ($state.snapshot(index) - 1) + " from playlist"); |
| 144 | + window.electron.ipcRenderer.send("removeFromPlaylist", {song: songInfo, playlist: $state.snapshot(playlist)}); |
| 145 | + closeMenu(); |
| 146 | + } |
| 147 | +
|
| 148 | + function addToPlaylist(playlist: PlaylistDataShort) { |
| 149 | + const songInfo: SongDataShort = { |
| 150 | + title: $state.snapshot(title), |
| 151 | + artistString: $state.snapshot(artistString), |
| 152 | + artists: $state.snapshot(artistList), |
| 153 | + album: $state.snapshot(album), |
| 154 | + identifier: $state.snapshot(identifier), |
| 155 | + source: $state.snapshot(source), |
| 156 | + duration: $state.snapshot(duration), |
| 157 | + }; |
| 158 | + console.log("adding to playlist") |
| 159 | + window.electron.ipcRenderer.send("addToPlaylist", {song: songInfo, playlist: playlist}); |
| 160 | + closeMenu(); |
| 161 | + } |
| 162 | +
|
128 | 163 | function clickedAlbum() { |
129 | 164 | if (!albumId || albumId == "") return; |
130 | 165 |
|
|
201 | 236 | opacity={contextMenuOpacity} |
202 | 237 | removeFromQueueCallback={removeFromQueue} |
203 | 238 | addAsNextCallback={addAsNext} |
| 239 | + addToPlaylistCallback={addToPlaylist} |
| 240 | + removeFromPlaylistCallback={removeFromPlaylist} |
204 | 241 | {queue} |
| 242 | + playlist={playlist == null ? false : true} |
| 243 | + source={source} |
205 | 244 | /> |
206 | 245 | {/if} |
207 | 246 | </div> |
|
0 commit comments