Implement Mac bounce feature

Closes #514
This commit is contained in:
Wesley van der Sanden
2017-11-09 15:01:47 +01:00
parent 5ccbeb080c
commit 53ba79294b
3 changed files with 68 additions and 2 deletions

View File

@@ -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({
</Checkbox>);
}
if (process.platform === 'darwin') {
options.push(
<FormGroup>
<Checkbox
inline={true}
key='bounceIcon'
id='inputBounceIcon'
ref='bounceIcon'
checked={this.state.notifications.bounceIcon}
onChange={this.handleBounceIcon}
style={{marginRight: '10px'}}
>{'Bounce the dock icon'}
</Checkbox>
<Radio
inline={true}
name='bounceIconType'
value='informational'
disabled={!this.state.notifications.bounceIcon}
defaultChecked={this.state.notifications.bounceIconType === 'informational'}
onChange={this.handleBounceIconType}
>{'once'}</Radio>
{' '}
<Radio
inline={true}
name='bounceIconType'
value='critical'
disabled={!this.state.notifications.bounceIcon}
defaultChecked={this.state.notifications.bounceIconType === 'critical'}
onChange={this.handleBounceIconType}
>{'until I open the app'}</Radio>
<HelpBlock
style={{marginLeft: '20px'}}
>
{'If enabled, the dock icon bounces once or until the user opens the app when a new message is received.'}
</HelpBlock>
</FormGroup>
);
}
if (process.platform === 'darwin' || process.platform === 'linux') {
options.push(
<Checkbox

View File

@@ -9,7 +9,9 @@ const defaultPreferences = {
trayIconTheme: 'light',
minimizeToTray: false,
notifications: {
flashWindow: 0
flashWindow: 0,
bounceIcon: 0,
bounceIconType: 'informational'
},
showUnreadBadge: true,
useSpellChecker: true,

View File

@@ -409,6 +409,10 @@ app.on('ready', () => {
mainWindow.flashFrame(true);
}
}
if (process.platform === 'darwin' && config.notifications.bounceIcon) {
app.dock.bounce(config.notifications.bounceIconType);
}
});
ipcMain.on('update-title', (event, arg) => {