Track history favicon keys
This commit is contained in:
@@ -44,7 +44,7 @@ impl BrowserCore {
|
||||
&& entry.space_id() == tab.space_id()
|
||||
&& entry.url() == tab.url()
|
||||
}) {
|
||||
entry.record_visit(tab.id().clone(), tab.title(), visited_at);
|
||||
entry.record_visit(tab.id().clone(), tab.title(), tab.favicon_key(), visited_at);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -54,10 +54,36 @@ impl BrowserCore {
|
||||
tab.id().clone(),
|
||||
tab.title(),
|
||||
tab.url().clone(),
|
||||
tab.favicon_key().map(ToOwned::to_owned),
|
||||
visited_at,
|
||||
));
|
||||
}
|
||||
|
||||
pub(super) fn set_history_favicon_key_for_tab(
|
||||
&mut self,
|
||||
tab: &BrowserTab,
|
||||
favicon_key: impl Into<String>,
|
||||
) {
|
||||
let favicon_key = favicon_key.into();
|
||||
if let Some(entry) = self.history_entries.iter_mut().find(|entry| {
|
||||
entry.profile_id() == tab.profile_id()
|
||||
&& entry.space_id() == tab.space_id()
|
||||
&& entry.url() == tab.url()
|
||||
}) {
|
||||
entry.set_favicon_key(favicon_key);
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn clear_history_favicon_key_for_tab(&mut self, tab: &BrowserTab) {
|
||||
if let Some(entry) = self.history_entries.iter_mut().find(|entry| {
|
||||
entry.profile_id() == tab.profile_id()
|
||||
&& entry.space_id() == tab.space_id()
|
||||
&& entry.url() == tab.url()
|
||||
}) {
|
||||
entry.clear_favicon_key();
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn find_history_match(&self, query: &str) -> Option<UrlText> {
|
||||
let normalized_query = query.trim().to_lowercase();
|
||||
if normalized_query.is_empty() {
|
||||
|
||||
@@ -279,22 +279,27 @@ impl BrowserCore {
|
||||
tab_id: &TabId,
|
||||
favicon_key: impl Into<String>,
|
||||
) -> Result<(), CoreError> {
|
||||
let tab = self
|
||||
let favicon_key = favicon_key.into();
|
||||
let tab_index = self
|
||||
.tabs
|
||||
.iter_mut()
|
||||
.find(|tab| tab.id() == tab_id)
|
||||
.iter()
|
||||
.position(|tab| tab.id() == tab_id)
|
||||
.ok_or_else(|| CoreError::TabNotFound { id: tab_id.clone() })?;
|
||||
tab.set_favicon_key(favicon_key)?;
|
||||
self.tabs[tab_index].set_favicon_key(favicon_key.clone())?;
|
||||
let tab = self.tabs[tab_index].clone();
|
||||
self.set_history_favicon_key_for_tab(&tab, favicon_key);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn clear_tab_favicon_key(&mut self, tab_id: &TabId) -> Result<(), CoreError> {
|
||||
let tab = self
|
||||
let tab_index = self
|
||||
.tabs
|
||||
.iter_mut()
|
||||
.find(|tab| tab.id() == tab_id)
|
||||
.iter()
|
||||
.position(|tab| tab.id() == tab_id)
|
||||
.ok_or_else(|| CoreError::TabNotFound { id: tab_id.clone() })?;
|
||||
tab.clear_favicon_key();
|
||||
self.tabs[tab_index].clear_favicon_key();
|
||||
let tab = self.tabs[tab_index].clone();
|
||||
self.clear_history_favicon_key_for_tab(&tab);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user