Open downloads from command bar
This commit is contained in:
@@ -6,13 +6,21 @@ use crate::CoreError;
|
||||
const DEFAULT_SEARCH_URL: &str = "https://duckduckgo.com/";
|
||||
|
||||
pub(crate) fn tab_title(url: &UrlText) -> String {
|
||||
if url.as_str() == "ely://new-tab" {
|
||||
return "New Tab".to_string();
|
||||
if let Some(title) = internal_page_title(url.as_str()) {
|
||||
return title.to_string();
|
||||
}
|
||||
|
||||
url.display_host()
|
||||
}
|
||||
|
||||
fn internal_page_title(url: &str) -> Option<&'static str> {
|
||||
match url {
|
||||
"ely://new-tab" => Some("New Tab"),
|
||||
"ely://downloads" => Some("Downloads"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn tab_matches_query(tab: &BrowserTab, normalized_query: &str) -> bool {
|
||||
tab.title().to_lowercase().contains(normalized_query)
|
||||
|| tab.url().as_str().to_lowercase().contains(normalized_query)
|
||||
@@ -59,3 +67,7 @@ pub(crate) fn search_url(query: &str) -> Result<UrlText, CoreError> {
|
||||
url.query_pairs_mut().append_pair("q", query);
|
||||
UrlText::parse(url.to_string()).map_err(CoreError::from)
|
||||
}
|
||||
|
||||
pub(crate) fn downloads_url() -> Result<UrlText, CoreError> {
|
||||
UrlText::parse("ely://downloads").map_err(CoreError::from)
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ use ely_domain::{CommandIntent, CommandScope, ProfileId, ProfileKind, SpaceId};
|
||||
use crate::{
|
||||
CoreError,
|
||||
navigation::{
|
||||
move_tab_space_name, new_profile_name, new_space_name, search_url, space_icon,
|
||||
switch_profile_name,
|
||||
downloads_url, move_tab_space_name, new_profile_name, new_space_name, search_url,
|
||||
space_icon, switch_profile_name,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -85,6 +85,10 @@ impl BrowserCore {
|
||||
self.open_tab(self.new_tab_url.clone());
|
||||
Ok(true)
|
||||
}
|
||||
"downloads" | "open-downloads" | "open downloads" => {
|
||||
self.open_tab(downloads_url()?);
|
||||
Ok(true)
|
||||
}
|
||||
"close-tab" => {
|
||||
self.close_active_tab()?;
|
||||
Ok(true)
|
||||
|
||||
Reference in New Issue
Block a user