electron: API tray.destroy is not working

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • 4.0.4
  • Operating System:
    • Ubuntu 18.10 x64

Expected Behavior

Observed in Zulip desktop app

  1. tray.destroy() api should destroy tray icon in panel
  2. show app tray icon option in general setting, it should destroy and create tray icon on toggle

Actual Behavior

Previous tray icon are not destroy on toggle and new icon created i.e tray.destroy API is not working

Screenshot from 2019-03-30 18-57-58

To Reproduce

$ git clone https://github.com/zulip/zulip-electron
$ cd zulip-electron
$ npm install
$ npm start

you can find code in zulip-electron/app/renderer/js/tray.js

function toggleTray() {
	let state;
	if (window.tray) {
		state = false;
		window.tray.destroy();
		if (window.tray.isDestroyed()) {
			window.tray = null;
		}
		ConfigUtil.setConfigItem('trayIcon', false);
	} else {
		state = true;
		createTray();
		if (process.platform === 'linux' || process.platform === 'win32') {
			renderNativeImage(unread).then(image => {
				window.tray.setImage(image);
				window.tray.setToolTip(unread + ' unread messages');
			});
		}
		ConfigUtil.setConfigItem('trayIcon', true);
	}
	const selector = 'webview:not([class*=disabled])';
	const webview = document.querySelector(selector);
	const webContents = webview.getWebContents();
	webContents.send('toggletray', state);
}

Screenshots

Image 2019-03-17 at 12 45 47 PM

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 49 (7 by maintainers)

Commits related to this issue

Most upvoted comments

@rrhythmsharma i’ve popped up a PR that i believe should ameliorate this!

This was closed due to inactivity, but It seems this is still not resolved. There is an active issue for keeweb project that is related to this.

same on v17.4.11.

haven’t tried the latest v21 though.

Just bumped from electron

  • “electron”: “8.2.0”, to
  • “electron”: “^13.1.9”,

and this bug started to appear. The destroy was working correctly before that.

@codebytere This doesn’t fix the issue. I think this needs to be reopened.

Perhaps you can rewrite the application with PWA and wasm.Though you need chrome ,the user experience will be better on every platforms.

But now I have to manage my codebase in five languages…GOD DAME

If you want a better Tray experience,you may want to try qt.But I wonder how they achieve it.

Oh sorry .GtkStatusion is a part of gnome so you don’t have to install it Manually . As for libappindicator1 ,you can install it with apt .But actually it doesn’t solve this issue.

you should try kde,at least it doesn’t crash