Move share command handling completely to ListView
This commit is contained in:
@@ -198,25 +198,6 @@ impl CommandManager {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
let queue = queue.clone();
|
|
||||||
self.register_command(
|
|
||||||
"share",
|
|
||||||
Some(Box::new(move |_, args| {
|
|
||||||
if let Some(url) = args.get(0).and_then(|source| match source.as_str() {
|
|
||||||
"current" => queue.get_current().and_then(|t| t.share_url()),
|
|
||||||
_ => None,
|
|
||||||
}) {
|
|
||||||
ClipboardProvider::new()
|
|
||||||
.and_then(|mut ctx: ClipboardContext| ctx.set_contents(url))
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(None)
|
|
||||||
})),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
let spotify = spotify.clone();
|
let spotify = spotify.clone();
|
||||||
self.register_command(
|
self.register_command(
|
||||||
|
|||||||
@@ -316,23 +316,22 @@ impl<I: ListItem + Clone> ViewExt for ListView<I> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if cmd == "share" {
|
if cmd == "share" {
|
||||||
return args.get(0).map_or_else(
|
return if let Some(url) = args.get(0).and_then(|source| match source.as_str() {
|
||||||
|| Err("wrong number of parameters".to_string()),
|
"selected" => self
|
||||||
|source| match source.as_str() {
|
.content
|
||||||
"selected" => {
|
.read()
|
||||||
if let Some(url) = self.content.read().ok().and_then(|content| {
|
.ok()
|
||||||
content.get(self.selected).and_then(ListItem::share_url)
|
.and_then(|content| content.get(self.selected).and_then(|i| i.share_url())), ,
|
||||||
}) {
|
"current" => self.queue.get_current().and_then(|t| t.share_url()),
|
||||||
ClipboardProvider::new()
|
_ => None,
|
||||||
.and_then(|mut ctx: ClipboardContext| ctx.set_contents(url))
|
}) {
|
||||||
.unwrap();
|
ClipboardProvider::new()
|
||||||
}
|
.and_then(|mut ctx: ClipboardContext| ctx.set_contents(url))
|
||||||
|
.ok();
|
||||||
Ok(CommandResult::Consumed(None))
|
Ok(CommandResult::Consumed(None))
|
||||||
}
|
} else {
|
||||||
_ => Ok(CommandResult::Ignored),
|
Ok(CommandResult::Ignored)
|
||||||
},
|
};
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd == "move" {
|
if cmd == "move" {
|
||||||
|
|||||||
Reference in New Issue
Block a user