diff --git a/_locales/_untranslated_en.json b/_locales/_untranslated_en.json
index ae5d225ec8..ef5718445f 100644
--- a/_locales/_untranslated_en.json
+++ b/_locales/_untranslated_en.json
@@ -10,5 +10,17 @@
},
"ask_delete_chat_desktop": {
"message": "Are you sure you want to delete \"%1$s\"?"
+ },
+ "pref_notifications": {
+ "message": "Enable notifications"
+ },
+ "pref_notifications_explain": {
+ "message": "Enable system notifications on new messages"
+ },
+ "pref_show_notification_content": {
+ "message": "Show message content in notification"
+ },
+ "pref_show_notification_content_explain": {
+ "message": "Shows sender and first words of message content in notification"
}
}
diff --git a/src/main/deltachat/login.js b/src/main/deltachat/login.js
index 9289517eb5..d061440719 100644
--- a/src/main/deltachat/login.js
+++ b/src/main/deltachat/login.js
@@ -2,6 +2,10 @@ const DeltaChat = require('deltachat-node')
const C = require('deltachat-node/constants')
const log = require('../../logger').getLogger('main/deltachat/login', true)
const path = require('path')
+const setupNotifications = require('../notifications')
+const setupUnreadBadgeCounter = require('../unread-badge')
+const { setupMarkseenFix } = require('../markseenFix')
+const { app } = require('electron')
const SplitOut = require('./splitout')
module.exports = class DCLoginController extends SplitOut {
@@ -24,8 +28,8 @@ module.exports = class DCLoginController extends SplitOut {
// Creates a separate DB file for each login
this._controller.fullCwd = this.getPath(credentials.addr)
log.info(`Using deltachat instance ${this._controller.fullCwd}`)
- this._controller._dc = new DeltaChat()
- const dc = this._dc
+ const dc = new DeltaChat()
+ this._controller._dc = dc
this._controller.credentials = credentials
this._controller._render = render
@@ -36,7 +40,7 @@ module.exports = class DCLoginController extends SplitOut {
return
}
- dc.open(this._controller.fullCwd, err => {
+ this._dc.open(this._controller.fullCwd, err => {
if (err) throw err
const onReady = () => {
log.info('Ready')
@@ -46,16 +50,19 @@ module.exports = class DCLoginController extends SplitOut {
log.info('dc_get_info', dc.getInfo())
render()
}
- if (!dc.isConfigured()) {
- dc.once('ready', onReady)
+ if (!this._dc.isConfigured()) {
+ this._dc.once('ready', onReady)
this._controller.configuring = true
- dc.configure(addServerFlags(credentials))
+ this._dc.configure(addServerFlags(credentials))
render()
} else {
onReady()
}
})
this._controller.registerEventHandler(dc)
+ setupNotifications(this._controller, app.state.saved)
+ setupUnreadBadgeCounter(this._controller)
+ setupMarkseenFix(this._controller)
}
logout () {
diff --git a/src/main/ipc.js b/src/main/ipc.js
index 260e25ae22..a918c3e655 100644
--- a/src/main/ipc.js
+++ b/src/main/ipc.js
@@ -23,10 +23,6 @@ const DeltaChat = (() => {
}
})()
const C = require('deltachat-node/constants')
-const setupNotifications = require('./notifications')
-const setupUnreadBadgeCounter = require('./unread-badge')
-
-const { setupMarkseenFix } = require('./markseenFix')
function init (cwd, state, logHandler) {
const main = windows.main
@@ -97,10 +93,6 @@ function init (cwd, state, logHandler) {
ipcMain.on('handleLogMessage', (e, ...args) => logHandler.log(...args))
- setupNotifications(dc, state.saved)
- setupUnreadBadgeCounter(dc)
- setupMarkseenFix(dc)
-
ipcMain.on('login', (e, credentials) => {
dc.loginController.login(credentials, render, txCoreStrings())
})
diff --git a/src/main/notifications.js b/src/main/notifications.js
index 640b6266d8..a09b6bec1f 100644
--- a/src/main/notifications.js
+++ b/src/main/notifications.js
@@ -23,7 +23,7 @@ module.exports = function (dc, settings) {
return `${summary.text1 || json.contact.displayName}: ${summary.text2}`
}
- dc.on('DC_EVENT_INCOMING_MSG', (chatId, msgId) => {
+ dc._dc.on('DC_EVENT_INCOMING_MSG', (chatId, msgId) => {
if (!notify && settings.notifications && windows.main.win.hidden) {
notify = new Notification({
title: appName(),
diff --git a/src/main/unread-badge.js b/src/main/unread-badge.js
index 20fb4f040b..b008e79603 100644
--- a/src/main/unread-badge.js
+++ b/src/main/unread-badge.js
@@ -13,7 +13,7 @@ module.exports = function (dc) {
app.setBadgeCount(count)
}
- dc.on('DC_EVENT_INCOMING_MSG', (chatId, msgId) => {
+ dc._dc.on('DC_EVENT_INCOMING_MSG', (chatId, msgId) => {
// don't update imidiately if the app is in focused
if (windows.main.win.hidden) update()
@@ -24,7 +24,7 @@ module.exports = function (dc) {
}, 4000)
})
- dc.on('ready', () => {
+ dc._dc.on('ready', () => {
// for start and after account switch
update()
})
diff --git a/src/renderer/components/dialogs/Settings.js b/src/renderer/components/dialogs/Settings.js
index 7dba00c275..0269e242a0 100644
--- a/src/renderer/components/dialogs/Settings.js
+++ b/src/renderer/components/dialogs/Settings.js
@@ -176,6 +176,9 @@ export default class Settings extends React.Component {
*/
handleDesktopSettingsChange (key, value) {
ipcRenderer.send('updateDesktopSetting', key, value)
+ if (key === 'notifications' && value === false) {
+ ipcRenderer.send('updateDesktopSetting', 'showNotificationContent', false)
+ }
}
/** Saves settings to deltachat core */
@@ -203,6 +206,7 @@ export default class Settings extends React.Component {
checked={settings[configKey]}
className={settings[configKey] ? 'active' : 'inactive'}
label={label}
+ disabled={configKey === 'showNotificationContent' && !settings['notifications']}
onChange={() => this.handleDesktopSettingsChange(configKey, !settings[configKey])}
/>
)}
@@ -288,6 +292,12 @@ export default class Settings extends React.Component {
{ this.renderDTSettingSwitch('enterKeySends', this.translate('pref_enter_sends')) }
{this.translate('pref_enter_sends_explain')}
+{this.translate('pref_notifications_explain')}
+{this.translate('pref_show_notification_content_explain')}