Skip to content

Commit

Permalink
Add Group Information to Tracking (#1266)
Browse files Browse the repository at this point in the history
Co-authored-by: Isaac <NoSpam>
  • Loading branch information
TheOverpassArsonist authored May 27, 2024
1 parent 525e034 commit 88d583b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/background/track.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import browser from "webextension-polyfill";
import browserInfo from "browser-info";
import log from "loglevel";
import { getSettings } from "src/settings/settings";
import { queryTabGroups } from "../common/tabGroups";
import { updateSession } from "./save";
import getSessions from "./getSessions";

const logDir = "background/track";
const isEnabledTabGroups = browserInfo().name == "Chrome" && browserInfo().version >= 89;

const setTrackingInfo = async (trackingWindows, isTracking) => {
await browser.storage.session.set({ trackingInfo: { trackingWindows, isTracking } });
Expand Down Expand Up @@ -47,6 +50,17 @@ export const updateTrackingSession = async (tempSession) => {
trackedSession.tabsNumber += Object.keys(win).length;
}

//Update Group Information
if (isEnabledTabGroups && getSettings("saveTabGroups")) {
const filteredWindows = Object.values(trackedSession.windowsInfo).filter(window => window.type === "normal");
const tabGroups = await Promise.all(filteredWindows.map(window => queryTabGroups({
windowId: window.id,
})));
const filteredTabGroups = tabGroups.flat().filter(tabGroup =>
Object.keys(trackedSession.windows).includes(String(tabGroup.windowId)));
if (filteredTabGroups.length > 0) trackedSession.tabGroups = filteredTabGroups;
}

await updateSession(trackedSession);
}
};
Expand Down

0 comments on commit 88d583b

Please sign in to comment.