Skip to content
Merged
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
48 changes: 30 additions & 18 deletions ui/desktop/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -764,30 +764,43 @@ const destroyTray = () => {
}
};

const disableTray = () => {
const settings = loadSettings();
settings.showMenuBarIcon = false;
saveSettings(settings);
};

const createTray = () => {
// If tray already exists, destroy it first
destroyTray();

const isDev = !app.isPackaged;
let iconPath: string;
const possiblePaths = [
path.join(process.resourcesPath, 'images', 'iconTemplate.png'),
path.join(process.cwd(), 'src', 'images', 'iconTemplate.png'),
path.join(__dirname, '..', 'images', 'iconTemplate.png'),
path.join(__dirname, 'images', 'iconTemplate.png'),
path.join(process.cwd(), 'images', 'iconTemplate.png'),
];

if (isDev) {
iconPath = path.join(process.cwd(), 'src', 'images', 'iconTemplate.png');
} else {
iconPath = path.join(process.resourcesPath, 'images', 'iconTemplate.png');
}

tray = new Tray(iconPath);
const iconPath = possiblePaths.find((p) => fsSync.existsSync(p));

// Set tray reference for auto-updater
setTrayRef(tray);
if (!iconPath) {
console.warn('[Main] Tray icon not found. App will continue without system tray.');
disableTray();
return;
}

// Initially build menu based on update status
updateTrayMenu(getUpdateAvailable());
try {
tray = new Tray(iconPath);
setTrayRef(tray);
updateTrayMenu(getUpdateAvailable());

// On Windows, clicking the tray icon should show the window
if (process.platform === 'win32') {
tray.on('click', showWindow);
if (process.platform === 'win32') {
tray.on('click', showWindow);
}
} catch (error) {
console.error('[Main] Tray creation failed. App will continue without system tray.', error);
disableTray();
tray = null;
}
};

Expand All @@ -802,7 +815,6 @@ const showWindow = async () => {
return;
}

// Define the initial offset values
const initialOffsetX = 30;
const initialOffsetY = 30;

Expand Down