mirror of
https://github.com/Dangoware/dango-music-player.git
synced 2025-06-22 22:52:59 -05:00
changed queue to use move_to instead of play_now when selecting a song from the queue
This commit is contained in:
parent
99bf0b6855
commit
407b53e941
7 changed files with 37 additions and 22 deletions
|
@ -109,10 +109,7 @@ pub enum LibraryCommand {
|
|||
AllSongs,
|
||||
GetLibrary,
|
||||
ExternalPlaylist(Uuid),
|
||||
PlaylistSong{
|
||||
list_uuid: Uuid,
|
||||
item_uuid: Uuid
|
||||
},
|
||||
PlaylistSong { list_uuid: Uuid, item_uuid: Uuid },
|
||||
Playlist(Uuid),
|
||||
ImportM3UPlayList(PathBuf),
|
||||
Save,
|
||||
|
@ -142,6 +139,7 @@ pub enum QueueCommand {
|
|||
Get,
|
||||
Clear,
|
||||
Remove(usize),
|
||||
MoveTo(usize),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use async_channel::{Receiver, Sender};
|
||||
use rcue::cue::Command;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::music_storage::{
|
||||
|
@ -108,6 +109,15 @@ impl ControllerHandle {
|
|||
queue
|
||||
}
|
||||
|
||||
pub async fn queue_move_to(&self, index: usize) -> Result<(), QueueError> {
|
||||
let (command, tx) = QueueCommandInput::command(QueueCommand::MoveTo(index));
|
||||
self.queue_mail_rx.send(command).await.unwrap();
|
||||
let QueueResponse::Empty(res) = tx.recv().await.unwrap() else {
|
||||
unreachable!()
|
||||
};
|
||||
res
|
||||
}
|
||||
|
||||
// The Player Section
|
||||
pub async fn play_now(&self, uuid: Uuid, location: PlayerLocation) -> Result<Song, QueueError> {
|
||||
let (command, tx) = PlayerCommandInput::command(PlayerCommand::PlayNow(uuid, location));
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
use rayon::iter::IndexedParallelIterator;
|
||||
|
||||
use crate::music_storage::queue::{Queue, QueueError, QueueItemType};
|
||||
|
||||
use super::{
|
||||
|
@ -69,6 +71,12 @@ impl Controller {
|
|||
.await
|
||||
.unwrap();
|
||||
}
|
||||
QueueCommand::MoveTo(index) => {
|
||||
res_rx
|
||||
.send(QueueResponse::Empty(queue.move_to(index)))
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,9 +30,9 @@ pub enum QueueItemType<
|
|||
}
|
||||
|
||||
impl<
|
||||
T: Debug + Clone + PartialEq, // T: The Singular Item Type
|
||||
U: Debug + PartialEq + Clone + IntoIterator, // U: The Multi-Item Type. Needs to be tracked as multiple items
|
||||
> QueueItemType<T, U>
|
||||
T: Debug + Clone + PartialEq, // T: The Singular Item Type
|
||||
U: Debug + PartialEq + Clone + IntoIterator, // U: The Multi-Item Type. Needs to be tracked as multiple items
|
||||
> QueueItemType<T, U>
|
||||
{
|
||||
pub fn from_single(item: T) -> Self {
|
||||
QueueItemType::Single(item)
|
||||
|
|
|
@ -25,7 +25,7 @@ use wrappers::{_Song, stop};
|
|||
|
||||
use crate::wrappers::{
|
||||
get_library, get_playlist, get_playlists, get_queue, get_song, import_playlist, next, pause,
|
||||
play, prev, remove_from_queue, seek, set_volume,
|
||||
play, prev, queue_move_to, remove_from_queue, seek, set_volume,
|
||||
};
|
||||
use commands::{add_song_to_queue, display_album_art, last_fm_init_auth, play_now};
|
||||
|
||||
|
@ -69,6 +69,7 @@ pub fn run() {
|
|||
save_config,
|
||||
close_window,
|
||||
start_controller,
|
||||
queue_move_to,
|
||||
// test_menu,
|
||||
])
|
||||
.manage(tempfile::TempDir::new().unwrap())
|
||||
|
|
|
@ -272,3 +272,14 @@ pub async fn get_song(
|
|||
pub async fn seek(ctrl_handle: State<'_, ControllerHandle>, time: i64) -> Result<(), String> {
|
||||
ctrl_handle.seek(time).await.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn queue_move_to(
|
||||
ctrl_handle: State<'_, ControllerHandle>,
|
||||
index: usize,
|
||||
) -> Result<(), String> {
|
||||
ctrl_handle
|
||||
.queue_move_to(index)
|
||||
.await
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
|
|
15
src/App.tsx
15
src/App.tsx
|
@ -277,19 +277,6 @@ function Song(props: SongProps) {
|
|||
menu.popup(pos);
|
||||
}
|
||||
|
||||
// useEffect(() => {
|
||||
// const unlistenPromise = listen<string>("add_song_to_queue", (event) => {
|
||||
// switch (event.payload) {
|
||||
// default:
|
||||
// console.log("Unimplemented application menu id:", event.payload);
|
||||
// }
|
||||
// });
|
||||
|
||||
// return () => {
|
||||
// unlistenPromise.then((unlisten) => unlisten());
|
||||
// };
|
||||
// }, []);
|
||||
|
||||
return(
|
||||
<div
|
||||
onDoubleClick={() => {
|
||||
|
@ -424,7 +411,7 @@ function QueueSong({ song, location, index }: QueueSongProps) {
|
|||
}
|
||||
|
||||
let playNow = () => {
|
||||
invoke('play_now', { uuid: song.uuid, location: location }).then(() => {})
|
||||
invoke('queue_move_to', { index: index }).then(() => {})
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
Loading…
Reference in a new issue