mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 17:41:40 -05:00
Added container color to the mode indicator. This functionality is hidden behind a config setting "containerindicator".
Related function 'activeTabContainer' was added to 'src/lib/webext.ts'. Minor changes to getFromId error handling in 'src/lib/containers.ts'.
This commit is contained in:
parent
dace4fb378
commit
01307ddc2c
4 changed files with 30 additions and 10 deletions
|
@ -297,6 +297,9 @@ const DEFAULTS = o({
|
|||
// If enabled, tabopen opens a new tab in the currently active tab's container.
|
||||
tabopencontaineraware: "false",
|
||||
|
||||
// If moodeindicator is enabled, containerindicator will color the border of the mode indicator with the container color.
|
||||
containerindicator: "true",
|
||||
|
||||
// Performance related settings
|
||||
|
||||
// number of most recent results to ask Firefox for. We display the top 20 or so most frequently visited ones.
|
||||
|
|
|
@ -83,6 +83,9 @@ if (
|
|||
config.getAsync("modeindicator").then(mode => {
|
||||
if (mode !== "true") return
|
||||
|
||||
// Do we want container indicators?
|
||||
let containerIndicator = config.get("containerindicator")
|
||||
|
||||
// Hide indicator in print mode
|
||||
// CSS not explicitly added to the dom doesn't make it to print mode:
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1448507
|
||||
|
@ -100,6 +103,22 @@ config.getAsync("modeindicator").then(mode => {
|
|||
: ""
|
||||
statusIndicator.className =
|
||||
"cleanslate TridactylStatusIndicator " + privateMode
|
||||
|
||||
// Dynamically sets the border container color.
|
||||
if (containerIndicator === "true") {
|
||||
webext
|
||||
.activeTabContainer()
|
||||
.then(container => {
|
||||
statusIndicator.setAttribute(
|
||||
"style",
|
||||
`border: ${container.colorCode} solid 1.5px !important`,
|
||||
)
|
||||
})
|
||||
.catch(error => {
|
||||
logger.debug(error)
|
||||
})
|
||||
}
|
||||
|
||||
// This listener makes the modeindicator disappear when the mouse goes over it
|
||||
statusIndicator.addEventListener("mouseenter", ev => {
|
||||
let target = ev.target as any
|
||||
|
|
|
@ -92,10 +92,7 @@ export async function update(
|
|||
icon: browser.contextualIdentities.IdentityIcon
|
||||
},
|
||||
) {
|
||||
if (
|
||||
isValidColor(updateObj["color"]) &&
|
||||
isValidIcon(updateObj["icon"])
|
||||
) {
|
||||
if (isValidColor(updateObj["color"]) && isValidIcon(updateObj["icon"])) {
|
||||
try {
|
||||
browser.contextualIdentities.update(containerId, updateObj)
|
||||
} catch (e) {
|
||||
|
@ -114,12 +111,7 @@ export async function getFromId(containerId: string): Promise<{}> {
|
|||
try {
|
||||
return await browser.contextualIdentities.get(containerId)
|
||||
} catch (e) {
|
||||
logger.debug(
|
||||
`[Container.getFromId] could not find a container with id: ${containerId}`,
|
||||
)
|
||||
throw new Error(
|
||||
"[Container.getFromId] could not find a container with that id",
|
||||
)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,12 @@ export async function activeTabContainerId() {
|
|||
return (await activeTab()).cookieStoreId
|
||||
}
|
||||
|
||||
//#background_helper
|
||||
export async function activeTabContainer() {
|
||||
let containerId = await activeTabContainerId()
|
||||
return await browserBg.contextualIdentities.get(containerId)
|
||||
}
|
||||
|
||||
/** Compare major firefox versions */
|
||||
export async function firefoxVersionAtLeast(desiredmajor: number) {
|
||||
const versionstr = (await browserBg.runtime.getBrowserInfo()).version
|
||||
|
|
Loading…
Add table
Reference in a new issue