Skip to content

Commit

Permalink
Ensure resetting the tray works (wulkano#711)
Browse files Browse the repository at this point in the history
  • Loading branch information
karaggeorge authored Sep 6, 2019
1 parent 9ff5c27 commit cc3fa05
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions main/common/aperture.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ const stopRecording = async () => {
} catch (error) {
track('recording/stopped/error');
dialog.showErrorBox('Recording error', error.message);
cleanup();
return;
}

Expand Down
4 changes: 3 additions & 1 deletion main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const {initializeTray} = require('./tray');
const plugins = require('./common/plugins');
const {initializeAnalytics} = require('./common/analytics');
const initializeExportList = require('./export-list');
const {openCropperWindow, isCropperOpen} = require('./cropper');
const {openCropperWindow, isCropperOpen, closeAllCroppers} = require('./cropper');
const {track} = require('./common/analytics');
const {initializeGlobalAccelerators} = require('./global-accelerators');
const {setApplicationMenu} = require('./menus');
Expand Down Expand Up @@ -98,6 +98,8 @@ const checkForUpdates = () => {
checkForUpdates();
})();

app.on('before-quit', closeAllCroppers);

app.on('window-all-closed', event => {
app.dock.hide();
event.preventDefault();
Expand Down
8 changes: 7 additions & 1 deletion main/tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {track} = require('./common/analytics');
const openFiles = require('./utils/open-files');

let tray = null;
let trayAnimation = null;

const openContextMenu = () => {
tray.popUpContextMenu(cogMenu);
Expand All @@ -32,6 +33,10 @@ const disableTray = () => {
};

const resetTray = () => {
if (trayAnimation) {
clearTimeout(trayAnimation);
}

tray.removeAllListeners('click');
tray.setImage(path.join(__dirname, '..', 'static', 'menubarDefaultTemplate.png'));
tray.on('click', openCropperWindow);
Expand All @@ -48,14 +53,15 @@ const animateIcon = () => new Promise(resolve => {
let i = 0;

const next = () => {
setTimeout(() => {
trayAnimation = setTimeout(() => {
const number = String(i++).padStart(5, '0');
const filename = `loading_${number}Template.png`;

try {
tray.setImage(path.join(__dirname, '..', 'static', 'menubar-loading', filename));
next();
} catch (_) {
trayAnimation = null;
resolve();
}
}, interval);
Expand Down

0 comments on commit cc3fa05

Please sign in to comment.