From 96c95eef18ddd6785c24ccac84610af469030d07 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Tue, 12 Mar 2019 23:30:36 -0700 Subject: [PATCH] Move default icon to a path preserved in packaged app --- app/build/tasks/installer-linux-task.js | 9 ++++++++- app/src/browser/autoupdate-manager.ts | 2 +- app/src/browser/mailspring-window.ts | 10 +--------- app/src/native-notifications.ts | 15 ++++++++++----- .../resources => static/images}/mailspring.png | Bin 5 files changed, 20 insertions(+), 16 deletions(-) rename app/{build/resources => static/images}/mailspring.png (100%) diff --git a/app/build/tasks/installer-linux-task.js b/app/build/tasks/installer-linux-task.js index 7f1b9af3c..fd4f44435 100644 --- a/app/build/tasks/installer-linux-task.js +++ b/app/build/tasks/installer-linux-task.js @@ -106,7 +106,14 @@ module.exports = grunt => { writeFromTemplate(path.join(linuxAssetsDir, 'mailspring.desktop.in'), data); writeFromTemplate(path.join(linuxAssetsDir, 'mailspring.appdata.xml.in'), data); - const icon = path.join(grunt.config('appDir'), 'build', 'resources', 'mailspring.png'); + const icon = path.join( + grunt.config('appDir'), + 'build', + 'resources', + 'linux', + 'icons', + '512.png' + ); const cmd = path.join(grunt.config('appDir'), 'script', 'mkdeb'); const args = [version, arch, icon, linuxAssetsDir, contentsDir, outputDir]; spawn({ cmd, args }, spawnError => { diff --git a/app/src/browser/autoupdate-manager.ts b/app/src/browser/autoupdate-manager.ts index 53f292f21..a81be1cff 100644 --- a/app/src/browser/autoupdate-manager.ts +++ b/app/src/browser/autoupdate-manager.ts @@ -162,7 +162,7 @@ export default class AutoUpdateManager extends EventEmitter { } iconURL() { - const url = path.join(process.resourcesPath, 'app', 'mailspring.png'); + const url = path.join(process.resourcesPath, 'static', 'images', 'mailspring.png'); if (!fs.existsSync(url)) { return undefined; } diff --git a/app/src/browser/mailspring-window.ts b/app/src/browser/mailspring-window.ts index 19bff9f17..01893b91f 100644 --- a/app/src/browser/mailspring-window.ts +++ b/app/src/browser/mailspring-window.ts @@ -114,16 +114,8 @@ export default class MailspringWindow extends EventEmitter { if (process.platform === 'linux') { if (!WindowIconPath) { WindowIconPath = path.resolve('/usr', 'share', 'pixmaps', 'mailspring.png'); - // Provides icon when running from npm start / development mode. if (!fs.existsSync(WindowIconPath)) { - WindowIconPath = path.resolve( - __dirname, - '..', - '..', - 'build', - 'resources', - 'mailspring.png' - ); + WindowIconPath = path.resolve(this.resourcePath, 'static', 'images', 'mailspring.png'); } } browserWindowOptions.icon = WindowIconPath; diff --git a/app/src/native-notifications.ts b/app/src/native-notifications.ts index 5a6507dc6..c19588aaa 100644 --- a/app/src/native-notifications.ts +++ b/app/src/native-notifications.ts @@ -5,7 +5,12 @@ import fs from 'fs'; import os from 'os'; const platform = process.platform; -const DEFAULT_ICON = path.resolve(__dirname, '..', 'build', 'resources', 'mailspring.png'); +const DEFAULT_ICON = path.resolve( + AppEnv.getLoadSettings().resourcePath, + 'static', + 'images', + 'mailspring.png' +); let MacNotifierNotification = null; if (platform === 'darwin') { @@ -13,13 +18,13 @@ if (platform === 'darwin') { MacNotifierNotification = require('node-mac-notifier'); } catch (err) { console.error( - 'node-mac-notifier (a platform-specific optionalDependency) was not installed correctly! Check the Travis build log for errors.', + 'node-mac-notifier (a platform-specific optionalDependency) was not installed correctly! Check the Travis build log for errors.' ); } } type INotificationCallback = ( - args: { response: string | null; activationType: 'replied' | 'clicked' }, + args: { response: string | null; activationType: 'replied' | 'clicked' } ) => any; type INotificationOptions = { @@ -29,7 +34,7 @@ type INotificationOptions = { tag?: string; canReply?: boolean; onActivate?: INotificationCallback; -} +}; class NativeNotifications { _macNotificationsByTag = {}; @@ -127,7 +132,7 @@ class NativeNotifications { body, tag, canReply, - onActivate = args => { }, + onActivate = args => {}, }: INotificationOptions = {}) { let notif = null; diff --git a/app/build/resources/mailspring.png b/app/static/images/mailspring.png similarity index 100% rename from app/build/resources/mailspring.png rename to app/static/images/mailspring.png