Add crashed tab recovery
This commit is contained in:
@@ -24,6 +24,7 @@ fn internal_page_title(url: &str) -> Option<&'static str> {
|
||||
"ely://archive" => Some("Archived Tabs"),
|
||||
"ely://task-manager" => Some("Task Manager"),
|
||||
"ely://plugins" => Some("Plugin Marketplace"),
|
||||
url if crash_route_tab_id(url).is_some() => Some("Tab Recovery"),
|
||||
url if plugin_detail_route_id(url).is_some() => Some("Plugin Details"),
|
||||
url if SiteOrigin::from_site_route(url).ok().flatten().is_some() => Some("Site Settings"),
|
||||
"ely://about" => Some("About ELY Browser"),
|
||||
@@ -248,3 +249,8 @@ fn plugin_detail_route_id(url: &str) -> Option<&str> {
|
||||
let plugin_id = url.strip_prefix("ely://plugin/")?;
|
||||
(!plugin_id.is_empty() && !plugin_id.contains('/')).then_some(plugin_id)
|
||||
}
|
||||
|
||||
pub(crate) fn crash_route_tab_id(url: &str) -> Option<&str> {
|
||||
let tab_id = url.strip_prefix("ely://crash/")?;
|
||||
(!tab_id.is_empty() && !tab_id.contains('/')).then_some(tab_id)
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ use sync::SyncObjectPolicies;
|
||||
|
||||
mod bookmarks;
|
||||
mod commands;
|
||||
mod crashes;
|
||||
mod downloads;
|
||||
mod history;
|
||||
mod notes;
|
||||
|
||||
@@ -273,6 +273,15 @@ impl BrowserCore {
|
||||
self.close_active_tab()?;
|
||||
Ok(true)
|
||||
}
|
||||
"crash-tab" | "crash tab" => {
|
||||
self.crash_active_tab()?;
|
||||
Ok(true)
|
||||
}
|
||||
"recover-tab" | "recover tab" | "recover-crashed-tab" | "recover crashed tab" => {
|
||||
let tab_id = self.active_tab()?.id().clone();
|
||||
self.recover_crashed_tab(&tab_id)?;
|
||||
Ok(true)
|
||||
}
|
||||
"close-split-view" | "close split view" => {
|
||||
Ok(self.close_active_saved_split_view()?.is_some())
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
use ely_domain::TabId;
|
||||
|
||||
use super::BrowserCore;
|
||||
use crate::CoreError;
|
||||
|
||||
impl BrowserCore {
|
||||
pub fn crash_active_tab(&mut self) -> Result<TabId, CoreError> {
|
||||
let tab_id = self.active_tab_id.clone();
|
||||
self.crash_tab(&tab_id)
|
||||
}
|
||||
|
||||
pub fn crash_tab(&mut self, tab_id: &TabId) -> Result<TabId, CoreError> {
|
||||
let tab = self
|
||||
.tabs
|
||||
.iter_mut()
|
||||
.find(|tab| tab.id() == tab_id)
|
||||
.ok_or_else(|| CoreError::TabNotFound { id: tab_id.clone() })?;
|
||||
tab.mark_crashed();
|
||||
Ok(tab_id.clone())
|
||||
}
|
||||
|
||||
pub fn recover_crashed_tab(&mut self, tab_id: &TabId) -> Result<TabId, CoreError> {
|
||||
{
|
||||
let tab = self
|
||||
.tabs
|
||||
.iter_mut()
|
||||
.find(|tab| tab.id() == tab_id)
|
||||
.ok_or_else(|| CoreError::TabNotFound { id: tab_id.clone() })?;
|
||||
tab.mark_ready();
|
||||
}
|
||||
|
||||
self.select_tab(tab_id)?;
|
||||
Ok(tab_id.clone())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user