Add title to LibraryNodeChildren
This commit is contained in:
parent
0731f61c41
commit
ffec874584
|
|
@ -26,6 +26,11 @@ service CrabidyService {
|
|||
rpc GetTrackUpdates(GetTrackUpdatesRequest) returns (stream GetTrackUpdatesResponse);
|
||||
}
|
||||
|
||||
message LibraryNodeChild {
|
||||
string uuid = 1;
|
||||
string title = 2;
|
||||
}
|
||||
|
||||
message GetQueueRequest {}
|
||||
message QueueTrackResponse {}
|
||||
message QueueLibraryNodeResponse {}
|
||||
|
|
@ -71,8 +76,8 @@ message Track {
|
|||
message LibraryNode {
|
||||
// Including provider
|
||||
string uuid = 1;
|
||||
string name = 2;
|
||||
repeated string children = 3;
|
||||
string title = 2;
|
||||
repeated LibraryNodeChild children = 3;
|
||||
optional string parent = 4;
|
||||
LibraryNodeState state = 5;
|
||||
repeated Track tracks = 6;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
pub mod proto;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use proto::crabidy::{LibraryNode, LibraryNodeState, Queue, Track};
|
||||
use proto::crabidy::{LibraryNode, LibraryNodeChild, LibraryNodeState, Queue, Track};
|
||||
|
||||
#[async_trait]
|
||||
pub trait ProviderClient: std::fmt::Debug + Send + Sync {
|
||||
|
|
@ -35,7 +35,7 @@ impl LibraryNode {
|
|||
pub fn new() -> Self {
|
||||
Self {
|
||||
uuid: "/".to_string(),
|
||||
name: "/".to_string(),
|
||||
title: "/".to_string(),
|
||||
children: Vec::new(),
|
||||
parent: None,
|
||||
state: LibraryNodeState::Unspecified as i32,
|
||||
|
|
@ -45,6 +45,12 @@ impl LibraryNode {
|
|||
}
|
||||
}
|
||||
|
||||
impl LibraryNodeChild {
|
||||
pub fn new(uuid: String, title: String) -> Self {
|
||||
Self { uuid, title }
|
||||
}
|
||||
}
|
||||
|
||||
pub enum QueueError {
|
||||
NotQueable,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ use crabidy_core::proto::crabidy::{
|
|||
GetActiveTrackRequest, GetActiveTrackResponse, GetLibraryNodeRequest, GetLibraryNodeResponse,
|
||||
GetQueueRequest, GetQueueResponse, GetQueueUpdatesRequest, GetQueueUpdatesResponse,
|
||||
GetTrackRequest, GetTrackResponse, GetTrackUpdatesRequest, GetTrackUpdatesResponse,
|
||||
LibraryNode, Queue, QueueLibraryNodeRequest, QueueLibraryNodeResponse, QueuePositionChange,
|
||||
QueueTrackRequest, QueueTrackResponse, RemoveTracksRequest, RemoveTracksResponse,
|
||||
ReplaceWithNodeRequest, ReplaceWithNodeResponse, ReplaceWithTrackRequest,
|
||||
LibraryNode, LibraryNodeChild, Queue, QueueLibraryNodeRequest, QueueLibraryNodeResponse,
|
||||
QueuePositionChange, QueueTrackRequest, QueueTrackResponse, RemoveTracksRequest,
|
||||
RemoveTracksResponse, ReplaceWithNodeRequest, ReplaceWithNodeResponse, ReplaceWithTrackRequest,
|
||||
ReplaceWithTrackResponse, SaveQueueRequest, SaveQueueResponse, SetCurrentTrackRequest,
|
||||
SetCurrentTrackResponse, StopRequest, StopResponse, TogglePlayRequest, TogglePlayResponse,
|
||||
Track,
|
||||
|
|
@ -148,7 +148,7 @@ impl ProviderOrchestrator {
|
|||
continue
|
||||
};
|
||||
tracks.extend(node.tracks);
|
||||
nodes_to_go.extend(node.children);
|
||||
nodes_to_go.extend(node.children.into_iter().map(|c| c.uuid))
|
||||
}
|
||||
tracks
|
||||
}
|
||||
|
|
@ -191,7 +191,8 @@ impl ProviderClient for ProviderOrchestrator {
|
|||
}
|
||||
fn get_lib_root(&self) -> LibraryNode {
|
||||
let mut root_node = LibraryNode::new();
|
||||
root_node.children.push("tidal".to_owned());
|
||||
let child = LibraryNodeChild::new("tidal".to_owned(), "tidal".to_owned());
|
||||
root_node.children.push(child);
|
||||
root_node
|
||||
}
|
||||
async fn get_lib_node(&self, uuid: &str) -> Result<LibraryNode, ProviderError> {
|
||||
|
|
|
|||
|
|
@ -65,10 +65,13 @@ impl crabidy_core::ProviderClient for Client {
|
|||
|
||||
fn get_lib_root(&self) -> crabidy_core::proto::crabidy::LibraryNode {
|
||||
let global_root = crabidy_core::proto::crabidy::LibraryNode::new();
|
||||
let children = vec!["userplaylists".to_string()];
|
||||
let children = vec![crabidy_core::proto::crabidy::LibraryNodeChild::new(
|
||||
"userplaylists".to_string(),
|
||||
"playlists".to_string(),
|
||||
)];
|
||||
crabidy_core::proto::crabidy::LibraryNode {
|
||||
uuid: "tidal".to_string(),
|
||||
name: "tidal".to_string(),
|
||||
title: "tidal".to_string(),
|
||||
parent: Some(format!("{}", global_root.uuid)),
|
||||
state: crabidy_core::proto::crabidy::LibraryNodeState::Done as i32,
|
||||
tracks: Vec::new(),
|
||||
|
|
@ -87,10 +90,9 @@ impl crabidy_core::ProviderClient for Client {
|
|||
let (module, uuid) = split_uuid(uuid);
|
||||
let node = match module.as_str() {
|
||||
"userplaylists" => {
|
||||
let global_root = crabidy_core::proto::crabidy::LibraryNode::new();
|
||||
let mut node = crabidy_core::proto::crabidy::LibraryNode {
|
||||
uuid: "userplaylists".to_string(),
|
||||
name: "playlists".to_string(),
|
||||
title: "playlists".to_string(),
|
||||
parent: Some("tidal".to_string()),
|
||||
state: crabidy_core::proto::crabidy::LibraryNodeState::Unspecified as i32,
|
||||
tracks: Vec::new(),
|
||||
|
|
@ -101,8 +103,11 @@ impl crabidy_core::ProviderClient for Client {
|
|||
.get_users_playlists_and_favorite_playlists(&user_id)
|
||||
.await?
|
||||
{
|
||||
node.children
|
||||
.push(format!("playlist:{}", playlist.playlist.uuid));
|
||||
let child = crabidy_core::proto::crabidy::LibraryNodeChild::new(
|
||||
format!("playlist:{}", playlist.playlist.uuid),
|
||||
playlist.playlist.title,
|
||||
);
|
||||
node.children.push(child);
|
||||
}
|
||||
node
|
||||
}
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ pub struct Playlist {
|
|||
impl From<Playlist> for crabidy_core::proto::crabidy::LibraryNode {
|
||||
fn from(a: Playlist) -> Self {
|
||||
crabidy_core::proto::crabidy::LibraryNode {
|
||||
name: a.title,
|
||||
title: a.title,
|
||||
uuid: format!("playlist:{}", a.uuid),
|
||||
tracks: Vec::new(),
|
||||
parent: None,
|
||||
|
|
|
|||
Loading…
Reference in New Issue