Skip to content

Commit

Permalink
added cleanup function
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian committed Apr 30, 2024
1 parent 9319bfa commit d101a6f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ function App() {
if (result.selectedThresholds) {
setSelectedThresholds(result.selectedThresholds);
}

cleanupMissingTabs();
});
}, []);

Expand Down Expand Up @@ -125,6 +127,23 @@ const handleDeleteTab = (id: number) => {
setSelectedThresholds(updatedThresholds);
};

// Function to remove missing tabs
const cleanupMissingTabs = () => {
chrome.tabs.query({}, (currentTabs: any[]) => {
const currentTabIds = currentTabs.map(tab => tab.id);

chrome.storage.local.get('tabs', (result: { tabs?: Tab[] }) => {
if (result.tabs) {
const updatedTabs = result.tabs.filter((tab: Tab) => currentTabIds.includes(tab.id));
chrome.storage.local.set({ tabs: updatedTabs }, () => {
console.log("Tabs in local storage updated after cleanup.");
});
}
});
});
};


return (
<div className="App">
<div className="logo-container" onClick={toggleSwitch}>
Expand Down

0 comments on commit d101a6f

Please sign in to comment.