Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Add monochrome tray icon" #1934

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed res/img/monochrome.ico
Binary file not shown.
Binary file removed res/img/monochrome.png
Binary file not shown.
5 changes: 2 additions & 3 deletions src/@types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ declare global {
var launcher: AutoLaunch;
var vectorConfig: Record<string, any>;
var trayConfig: {
color_icon_path: string; // eslint-disable-line camelcase
monochrome_icon_path: string; // eslint-disable-line camelcase
// eslint-disable-next-line camelcase
icon_path: string;
brand: string;
};
var store: Store<{
Expand All @@ -31,7 +31,6 @@ declare global {
autoHideMenuBar?: boolean;
locale?: string | string[];
disableHardwareAcceleration?: boolean;
monochromeIcon?: boolean;
}>;
}
/* eslint-enable no-var */
8 changes: 3 additions & 5 deletions src/electron-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,9 @@ async function setupGlobals(): Promise<void> {

// The tray icon
// It's important to call `path.join` so we don't end up with the packaged asar in the final path.
const colorIconFile = `element.${process.platform === "win32" ? "ico" : "png"}`;
const monochromeIconFile = `monochrome.${process.platform === "win32" ? "ico" : "png"}`;
const iconFile = `element.${process.platform === "win32" ? "ico" : "png"}`;
global.trayConfig = {
monochrome_icon_path: path.join(resPath, "img", monochromeIconFile),
color_icon_path: path.join(resPath, "img", colorIconFile),
icon_path: path.join(resPath, "img", iconFile),
brand: global.vectorConfig.brand || "Element",
};

Expand Down Expand Up @@ -455,7 +453,7 @@ app.on("ready", async () => {
titleBarStyle: process.platform === "darwin" ? "hidden" : "default",
trafficLightPosition: { x: 9, y: 8 },

icon: global.trayConfig.color_icon_path,
icon: global.trayConfig.icon_path,
show: false,
autoHideMenuBar: global.store.get("autoHideMenuBar", true),

Expand Down
9 changes: 0 additions & 9 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,4 @@ export const Settings: Record<string, Setting> = {
global.store.set("disableHardwareAcceleration", !value);
},
},
"Electron.monochromeIcon": {
async read(): Promise<any> {
return tray.isMonochrome();
},
async write(value: any): Promise<void> {
global.store.set("monochromeIcon", value);
tray.refreshIcon();
},
},
};
20 changes: 2 additions & 18 deletions src/tray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,6 @@ export function destroy(): void {
}
}

export function isMonochrome(): boolean {
return global.store.get("monochromeIcon", process.platform === "linux");
}

export function refreshIcon(): void {
const monochrome = isMonochrome();
if (monochrome) {
trayIcon?.setImage(nativeImage.createFromPath(global.trayConfig.monochrome_icon_path));
} else {
trayIcon?.setImage(nativeImage.createFromPath(global.trayConfig.color_icon_path));
}
}

function toggleWin(): void {
if (global.mainWindow?.isVisible() && !global.mainWindow.isMinimized() && global.mainWindow.isFocused()) {
global.mainWindow.hide();
Expand All @@ -52,8 +39,7 @@ function toggleWin(): void {
}

interface IConfig {
color_icon_path: string; // eslint-disable-line camelcase
monochrome_icon_path: string; // eslint-disable-line camelcase
icon_path: string; // eslint-disable-line camelcase
brand: string;
}

Expand All @@ -66,9 +52,7 @@ function getUuid(): string {
export function create(config: IConfig): void {
// no trays on darwin
if (process.platform === "darwin" || trayIcon) return;
const defaultIcon = nativeImage.createFromPath(
isMonochrome() ? config.monochrome_icon_path : config.color_icon_path,
);
const defaultIcon = nativeImage.createFromPath(config.icon_path);

let guid: string | undefined;
if (process.platform === "win32" && app.isPackaged) {
Expand Down
Loading