mirror of
https://github.com/zen-browser/components.git
synced 2025-07-08 01:20:00 +02:00
fix(pinned-tabs): Always update pinned tab data with latest information
This commit ensures that pinned tab data is always updated with the latest information, and previous tab entries are cleaned up.
This commit is contained in:
parent
89f6a07353
commit
dab9e1edcc
1 changed files with 6 additions and 23 deletions
|
@ -71,18 +71,9 @@ class ZenPinnedTabManager {
|
|||
const tabState = SessionStore.getTabState(tab);
|
||||
const state = JSON.parse(tabState);
|
||||
|
||||
if(!!state.entries.length) {
|
||||
let activeIndex = (state.index || state.entries.length) - 1;
|
||||
activeIndex = Math.min(activeIndex, state.entries.length - 1);
|
||||
activeIndex = Math.max(activeIndex, 0);
|
||||
|
||||
state.entries[activeIndex].url = url;
|
||||
state.entries[activeIndex].title = title;
|
||||
state.image = icon;
|
||||
} else {
|
||||
state.entries.push({ url, title, image: icon });
|
||||
}
|
||||
|
||||
state.entries = [{url, title}];
|
||||
state.image = icon;
|
||||
state.index = 0;
|
||||
|
||||
SessionStore.setTabState(tab, state);
|
||||
}
|
||||
|
@ -147,17 +138,9 @@ class ZenPinnedTabManager {
|
|||
const tabState = SessionStore.getTabState(selectedTab);
|
||||
const state = JSON.parse(tabState);
|
||||
|
||||
if(!!state.entries.length) {
|
||||
let activeIndex = (state.index || state.entries.length) - 1;
|
||||
activeIndex = Math.min(activeIndex, state.entries.length - 1);
|
||||
activeIndex = Math.max(activeIndex, 0);
|
||||
|
||||
state.entries[activeIndex].url = url;
|
||||
state.entries[activeIndex].title = title;
|
||||
state.image = icon;
|
||||
} else {
|
||||
state.entries.push({ url, title, image: icon });
|
||||
}
|
||||
state.entries = [{url, title}];
|
||||
state.image = icon;
|
||||
state.index = 0;
|
||||
|
||||
SessionStore.setTabState(selectedTab, state);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue