refactored out the usage of ui.showTray to use appState