From 53ba79294bc35379d525dc9ac3525a27467578d1 Mon Sep 17 00:00:00 2001 From: Wesley van der Sanden Date: Thu, 9 Nov 2017 15:01:47 +0100 Subject: [PATCH 1/5] Implement Mac bounce feature Closes #514 --- src/browser/components/SettingsPage.jsx | 62 ++++++++++++++++++++++++- src/common/config/defaultPreferences.js | 4 +- src/main.js | 4 ++ 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/src/browser/components/SettingsPage.jsx b/src/browser/components/SettingsPage.jsx index 9d4d6ac2..a7b298c5 100644 --- a/src/browser/components/SettingsPage.jsx +++ b/src/browser/components/SettingsPage.jsx @@ -129,7 +129,9 @@ const SettingsPage = createReactClass({ version: settings.version, minimizeToTray: this.state.minimizeToTray, notifications: { - flashWindow: this.state.notifications.flashWindow + flashWindow: this.state.notifications.flashWindow, + bounceIcon: this.state.notifications.bounceIcon, + bounceIconType: this.state.notifications.bounceIconType }, showUnreadBadge: this.state.showUnreadBadge, useSpellChecker: this.state.useSpellChecker, @@ -219,11 +221,30 @@ const SettingsPage = createReactClass({ handleFlashWindow() { this.setState({ notifications: { + ...this.state.notifications, flashWindow: this.refs.flashWindow.props.checked ? 0 : 2 } }); setImmediate(this.startSaveConfig, CONFIG_TYPE_APP_OPTIONS); }, + handleBounceIcon() { + this.setState({ + notifications: { + ...this.state.notifications, + bounceIcon: !this.refs.bounceIcon.props.checked + } + }); + setImmediate(this.startSaveConfig, CONFIG_TYPE_APP_OPTIONS); + }, + handleBounceIconType(event) { + this.setState({ + notifications: { + ...this.state.notifications, + bounceIconType: event.target.value + } + }); + setImmediate(this.startSaveConfig, CONFIG_TYPE_APP_OPTIONS); + }, handleShowUnreadBadge() { this.setState({ showUnreadBadge: !this.refs.showUnreadBadge.props.checked @@ -419,6 +440,45 @@ const SettingsPage = createReactClass({ ); } + if (process.platform === 'darwin') { + options.push( + + {'Bounce the dock icon'} + + {'once'} + {' '} + {'until I open the app'} + + {'If enabled, the dock icon bounces once or until the user opens the app when a new message is received.'} + + + ); + } + if (process.platform === 'darwin' || process.platform === 'linux') { options.push( { mainWindow.flashFrame(true); } } + + if (process.platform === 'darwin' && config.notifications.bounceIcon) { + app.dock.bounce(config.notifications.bounceIconType); + } }); ipcMain.on('update-title', (event, arg) => { From 5cf940b3147fb14b6b4d55fe7af0a1239be852a7 Mon Sep 17 00:00:00 2001 From: Wesley van der Sanden Date: Mon, 13 Nov 2017 23:22:44 +0100 Subject: [PATCH 2/5] Change default setting from 0 to false GH-514 --- src/common/config/defaultPreferences.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/config/defaultPreferences.js b/src/common/config/defaultPreferences.js index 3d7552b9..bb2538a8 100644 --- a/src/common/config/defaultPreferences.js +++ b/src/common/config/defaultPreferences.js @@ -10,7 +10,7 @@ const defaultPreferences = { minimizeToTray: false, notifications: { flashWindow: 0, - bounceIcon: 0, + bounceIcon: false, bounceIconType: 'informational' }, showUnreadBadge: true, From f970fda2e3172bcfe48a36e0a770dcc8dc6dbe79 Mon Sep 17 00:00:00 2001 From: Wesley van der Sanden Date: Tue, 14 Nov 2017 22:19:43 +0100 Subject: [PATCH 3/5] Select 'Once' option by default Also fixes a small typo in an unrelated part of the code. GH-514 --- src/browser/components/SettingsPage.jsx | 5 ++++- src/common/settings.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/browser/components/SettingsPage.jsx b/src/browser/components/SettingsPage.jsx index a7b298c5..6cc0eaf8 100644 --- a/src/browser/components/SettingsPage.jsx +++ b/src/browser/components/SettingsPage.jsx @@ -458,7 +458,10 @@ const SettingsPage = createReactClass({ name='bounceIconType' value='informational' disabled={!this.state.notifications.bounceIcon} - defaultChecked={this.state.notifications.bounceIconType === 'informational'} + defaultChecked={ + !this.state.notifications.bounceIconType || + this.state.notifications.bounceIconType === 'informational' + } onChange={this.handleBounceIconType} >{'once'} {' '} diff --git a/src/common/settings.js b/src/common/settings.js index b435d504..51fae547 100644 --- a/src/common/settings.js +++ b/src/common/settings.js @@ -14,7 +14,7 @@ const upgradePreferences = require('./config/upgradePreferences'); function loadDefault(spellCheckerLocale) { const config = JSON.parse(JSON.stringify(defaultPreferences)); return Object.assign({}, config, { - spellCheckerLocale: spellCheckerLocale || defaultPreferences.pellCheckerLocale || 'en-US' + spellCheckerLocale: spellCheckerLocale || defaultPreferences.spellCheckerLocale || 'en-US' }); } From c315323545199e93117f4868fc3f481fa893c3aa Mon Sep 17 00:00:00 2001 From: Jason Blais Date: Wed, 15 Nov 2017 10:07:56 -0500 Subject: [PATCH 4/5] Update SettingsPage.jsx --- src/browser/components/SettingsPage.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/browser/components/SettingsPage.jsx b/src/browser/components/SettingsPage.jsx index 6cc0eaf8..4604b1fa 100644 --- a/src/browser/components/SettingsPage.jsx +++ b/src/browser/components/SettingsPage.jsx @@ -451,7 +451,7 @@ const SettingsPage = createReactClass({ checked={this.state.notifications.bounceIcon} onChange={this.handleBounceIcon} style={{marginRight: '10px'}} - >{'Bounce the dock icon'} + >{'Bounce the Dock icon'} - {'If enabled, the dock icon bounces once or until the user opens the app when a new message is received.'} + {'If enabled, the Dock icon bounces once or until the user opens the app when a new message is received.'} ); From 3bd267c660405eedbe2f74c8cefa224acad82d46 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Thu, 16 Nov 2017 00:40:12 +0900 Subject: [PATCH 5/5] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a5668b6..a08e157a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,8 @@ Release date: TBD [#512](https://github.com/mattermost/desktop/issues/512) - Added the feature to open the application via `mattermost://` link. [#616](https://github.com/mattermost/desktop/pull/616) + - Added the option to bounce the Dock icon when receiving new messages. + [#514](https://github.com/mattermost/desktop/issues/514) ### Bug Fixes