Skip to content

Commit

Permalink
chore: added random color to firefox containers
Browse files Browse the repository at this point in the history
  • Loading branch information
rick-rtt committed Nov 9, 2022
1 parent ef4d1f9 commit a39abb9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/backend/models/container-colors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const containerColors = ["toolbar", "pink", "orange", "green", "red", "blue", "purple", "turquoise", "yellow"];
8 changes: 7 additions & 1 deletion src/backend/services/tab-controller.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ExtensionStateService } from "./extension-state.service";
import { LeappSessionInfo } from "../models/leapp-session-info";
import { containerColors } from "../models/container-colors";

export class TabControllerService {
constructor(private chromeNamespace: typeof chrome, private state: ExtensionStateService) {}
Expand Down Expand Up @@ -50,7 +51,12 @@ export class TabControllerService {
}

private async newFirefoxSessionTab(url: string, containerName: string, sessionId: number) {
const container = await this.getBrowser().contextualIdentities.create({ name: containerName, color: "orange", icon: "circle" });
const colorIndex = this.state.sessionCounter % containerColors.length;
const container = await this.getBrowser().contextualIdentities.create({
name: containerName,
color: containerColors[colorIndex],
icon: "circle",
});
this.state.setCookieStoreId(sessionId, container.cookieStoreId);
await this.getBrowser().tabs.create({
url,
Expand Down

0 comments on commit a39abb9

Please sign in to comment.