From 50bb99d8905b8360aec4346078742bc3c38b2fa2 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Thu, 28 Sep 2017 00:05:06 -0700 Subject: [PATCH] Merge electron-lets-move into application (main process) --- .../lib/items/update-notification.jsx | 4 +- .../verify-install-location/lib/main.es6 | 33 ------------ .../verify-install-location/package.json | 13 ----- app/src/browser/application.es6 | 52 ++++++++++++++----- 4 files changed, 42 insertions(+), 60 deletions(-) delete mode 100644 app/internal_packages/verify-install-location/lib/main.es6 delete mode 100644 app/internal_packages/verify-install-location/package.json diff --git a/app/internal_packages/notifications/lib/items/update-notification.jsx b/app/internal_packages/notifications/lib/items/update-notification.jsx index 90f5ab548..4d3693a33 100644 --- a/app/internal_packages/notifications/lib/items/update-notification.jsx +++ b/app/internal_packages/notifications/lib/items/update-notification.jsx @@ -48,7 +48,9 @@ export default class UpdateNotification extends React.Component { return ( tile-datafile-data_CFURLString${appPath.split( - '.app/' - )[0]}.app/_CFURLStringType0"` - ); - config.set('addedToDock', true); - } - } } getMainWindow() { @@ -160,6 +151,41 @@ export default class Application extends EventEmitter { } } + async oneTimeMoveToApplications() { + if (this.devMode || this.specMode) { + return; + } + if (this.config.get('askedAboutAppMove')) { + return; + } + try { + await moveToApplications(); + this.config.set('askedAboutAppMove', true); + } catch (err) { + dialog.showMessageBox({ + type: 'warning', + buttons: ['Okay'], + message: `We encountered a problem moving to the Applications folder. Try quitting the application and moving it manually.`, + detail: err.toString(), + }); + } + } + + async oneTimeAddToDock() { + if (process.platform !== 'darwin') { + return; + } + const addedToDock = this.config.get('addedToDock'); + const appPath = process.argv[0]; + if (!addedToDock && appPath.includes('/Applications/') && appPath.includes('.app/')) { + const appBundlePath = appPath.split('.app/')[0]; + proc.exec( + `defaults write com.apple.dock persistent-apps -array-add "tile-datafile-data_CFURLString${appBundlePath}.app/_CFURLStringType0"` + ); + this.config.set('addedToDock', true); + } + } + // On Windows, removing a file can fail if a process still has it open. When // we close windows and log out, we need to wait for these processes to completely // exit and then delete the file. It's hard to tell when this happens, so we just