From c381775c9783b2af8c8ecc2c55e76aaab42ed3ef Mon Sep 17 00:00:00 2001 From: vantezzen Date: Sun, 8 Sep 2019 10:44:12 +0200 Subject: Implement meetfranz/franz#879 --- .../settings/settings/EditSettingsForm.js | 1 + src/config.js | 1 + src/containers/settings/EditSettingsScreen.js | 10 ++++ src/i18n/locales/en-US.json | 1 + .../containers/settings/EditSettingsScreen.json | 53 ++++++++++++++-------- src/stores/ServicesStore.js | 13 +++++- 6 files changed, 57 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/components/settings/settings/EditSettingsForm.js b/src/components/settings/settings/EditSettingsForm.js index b59e3a74a..d3a1ede82 100644 --- a/src/components/settings/settings/EditSettingsForm.js +++ b/src/components/settings/settings/EditSettingsForm.js @@ -172,6 +172,7 @@ export default @observer class EditSettingsForm extends Component { + {process.platform === 'win32' && ( )} diff --git a/src/config.js b/src/config.js index 06b4b79a9..3e0000a57 100644 --- a/src/config.js +++ b/src/config.js @@ -36,6 +36,7 @@ export const DEFAULT_APP_SETTINGS = { runInBackground: true, enableSystemTray: true, minimizeToSystemTray: false, + privateNotifications: false, server: LIVE_API, todoServer: PRODUCTION_TODOS_FRONTEND_URL, showDisabledServices: true, diff --git a/src/containers/settings/EditSettingsScreen.js b/src/containers/settings/EditSettingsScreen.js index d03b01539..73385d7b8 100644 --- a/src/containers/settings/EditSettingsScreen.js +++ b/src/containers/settings/EditSettingsScreen.js @@ -43,6 +43,10 @@ const messages = defineMessages({ id: 'settings.app.form.minimizeToSystemTray', defaultMessage: '!!!Minimize Ferdi to system tray', }, + privateNotifications: { + id: 'settings.app.form.privateNotifications', + defaultMessage: '!!!Don\'t show message content in notifications', + }, server: { id: 'settings.app.form.server', defaultMessage: '!!!Server', @@ -110,6 +114,7 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e runInBackground: settingsData.runInBackground, enableSystemTray: settingsData.enableSystemTray, minimizeToSystemTray: settingsData.minimizeToSystemTray, + privateNotifications: settingsData.privateNotifications, server: settingsData.server, todoServer: settingsData.todoServer, enableGPUAcceleration: settingsData.enableGPUAcceleration, @@ -177,6 +182,11 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e value: settings.all.app.minimizeToSystemTray, default: DEFAULT_APP_SETTINGS.minimizeToSystemTray, }, + privateNotifications: { + label: intl.formatMessage(messages.privateNotifications), + value: settings.all.app.privateNotifications, + default: DEFAULT_APP_SETTINGS.privateNotifications, + }, server: { label: intl.formatMessage(messages.server), value: settings.all.app.server || API, diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json index 67f80bf18..7d397b4d3 100644 --- a/src/i18n/locales/en-US.json +++ b/src/i18n/locales/en-US.json @@ -214,6 +214,7 @@ "settings.app.form.enableTodos": "Enable Ferdi Todos", "settings.app.form.language": "Language", "settings.app.form.minimizeToSystemTray": "Minimize Ferdi to system tray", + "settings.app.form.privateNotifications": "Don't show message content in notifications", "settings.app.form.runInBackground": "Keep Ferdi in background when closing the window", "settings.app.form.server": "Server", "settings.app.form.showDisabledServices": "Display disabled services tabs", diff --git a/src/i18n/messages/src/containers/settings/EditSettingsScreen.json b/src/i18n/messages/src/containers/settings/EditSettingsScreen.json index 70ec74ada..d50389066 100644 --- a/src/i18n/messages/src/containers/settings/EditSettingsScreen.json +++ b/src/i18n/messages/src/containers/settings/EditSettingsScreen.json @@ -64,16 +64,29 @@ "column": 3 } }, + { + "id": "settings.app.form.privateNotifications", + "defaultMessage": "!!!Don't show message content in notifications", + "file": "src/containers/settings/EditSettingsScreen.js", + "start": { + "line": 46, + "column": 24 + }, + "end": { + "line": 49, + "column": 3 + } + }, { "id": "settings.app.form.server", "defaultMessage": "!!!Server", "file": "src/containers/settings/EditSettingsScreen.js", "start": { - "line": 46, + "line": 50, "column": 10 }, "end": { - "line": 49, + "line": 53, "column": 3 } }, @@ -82,11 +95,11 @@ "defaultMessage": "!!!Todo Server", "file": "src/containers/settings/EditSettingsScreen.js", "start": { - "line": 50, + "line": 54, "column": 14 }, "end": { - "line": 53, + "line": 57, "column": 3 } }, @@ -95,11 +108,11 @@ "defaultMessage": "!!!Language", "file": "src/containers/settings/EditSettingsScreen.js", "start": { - "line": 54, + "line": 58, "column": 12 }, "end": { - "line": 57, + "line": 61, "column": 3 } }, @@ -108,11 +121,11 @@ "defaultMessage": "!!!Dark Mode", "file": "src/containers/settings/EditSettingsScreen.js", "start": { - "line": 58, + "line": 62, "column": 12 }, "end": { - "line": 61, + "line": 65, "column": 3 } }, @@ -121,11 +134,11 @@ "defaultMessage": "!!!Display disabled services tabs", "file": "src/containers/settings/EditSettingsScreen.js", "start": { - "line": 62, + "line": 66, "column": 24 }, "end": { - "line": 65, + "line": 69, "column": 3 } }, @@ -134,11 +147,11 @@ "defaultMessage": "!!!Show unread message badge when notifications are disabled", "file": "src/containers/settings/EditSettingsScreen.js", "start": { - "line": 66, + "line": 70, "column": 29 }, "end": { - "line": 69, + "line": 73, "column": 3 } }, @@ -147,11 +160,11 @@ "defaultMessage": "!!!Enable spell checking", "file": "src/containers/settings/EditSettingsScreen.js", "start": { - "line": 70, + "line": 74, "column": 23 }, "end": { - "line": 73, + "line": 77, "column": 3 } }, @@ -160,11 +173,11 @@ "defaultMessage": "!!!Enable GPU Acceleration", "file": "src/containers/settings/EditSettingsScreen.js", "start": { - "line": 74, + "line": 78, "column": 25 }, "end": { - "line": 77, + "line": 81, "column": 3 } }, @@ -173,11 +186,11 @@ "defaultMessage": "!!!Include beta versions", "file": "src/containers/settings/EditSettingsScreen.js", "start": { - "line": 78, + "line": 82, "column": 8 }, "end": { - "line": 81, + "line": 85, "column": 3 } }, @@ -186,11 +199,11 @@ "defaultMessage": "!!!Enable Franz Todos", "file": "src/containers/settings/EditSettingsScreen.js", "start": { - "line": 82, + "line": 86, "column": 15 }, "end": { - "line": 85, + "line": 89, "column": 3 } } diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 876851a66..3ee799b69 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js @@ -399,8 +399,17 @@ export default class ServicesStore extends Store { } if (service.isNotificationEnabled) { - const title = typeof args[0].title === 'string' ? args[0].title : service.name; - options.body = typeof options.body === 'string' ? options.body : ''; + let title = 'Notification from ' + service.name; + if (!this.stores.settings.all.app.privateNotifications) { + options.body = typeof options.body === 'string' ? options.body : ''; + title = typeof args[0].title === 'string' ? args[0].title : service.name; + } else { + // Remove message data from notification in private mode + options.body = ''; + options.icon = '/assets/img/notification-badge.gif'; + } + + console.log(title, options) this.actions.app.notify({ notificationId: args[0].notificationId, -- cgit v1.2.3-70-g09d2