Added 'default' option to channel notification settings that just uses the user's notification level

Этот коммит содержится в:
hmhealey
2015-09-22 12:00:34 -04:00
родитель 8a5ab6a56f
Коммит 4bc625e8d1
5 изменённых файлов: 65 добавлений и 39 удалений

Просмотреть файл

@@ -104,14 +104,28 @@ export default class ChannelNotifications extends React.Component {
createDesktopSection(serverError) {
var handleUpdateSection;
const user = UserStore.getCurrentUser();
const globalNotifyLevel = user.notify_props.desktop;
let globalNotifyLevelName;
if (globalNotifyLevel === 'all') {
globalNotifyLevelName = 'For all activity';
} else if (globalNotifyLevel === 'mention') {
globalNotifyLevelName = 'Only for mentions';
} else {
globalNotifyLevelName = 'Never';
}
if (this.state.activeSection === 'desktop') {
var notifyActive = [false, false, false];
if (this.state.notifyLevel === 'mention') {
notifyActive[1] = true;
} else if (this.state.notifyLevel === 'all') {
var notifyActive = [false, false, false, false];
if (this.state.notifyLevel === 'default') {
notifyActive[0] = true;
} else {
} else if (this.state.notifyLevel === 'all') {
notifyActive[1] = true;
} else if (this.state.notifyLevel === 'mention') {
notifyActive[2] = true;
} else {
notifyActive[3] = true;
}
var inputs = [];
@@ -123,9 +137,9 @@ export default class ChannelNotifications extends React.Component {
<input
type='radio'
checked={notifyActive[0]}
onChange={this.handleRadioClick.bind(this, 'all')}
onChange={this.handleRadioClick.bind(this, 'default')}
>
For all activity
{`Global default (${globalNotifyLevelName})`}
</input>
</label>
<br/>
@@ -135,9 +149,9 @@ export default class ChannelNotifications extends React.Component {
<input
type='radio'
checked={notifyActive[1]}
onChange={this.handleRadioClick.bind(this, 'mention')}
onChange={this.handleRadioClick.bind(this, 'all')}
>
Only for mentions
{'For all activity'}
</input>
</label>
<br/>
@@ -147,9 +161,21 @@ export default class ChannelNotifications extends React.Component {
<input
type='radio'
checked={notifyActive[2]}
onChange={this.handleRadioClick.bind(this, 'mention')}
>
{'Only for mentions'}
</input>
</label>
<br/>
</div>
<div className='radio'>
<label>
<input
type='radio'
checked={notifyActive[3]}
onChange={this.handleRadioClick.bind(this, 'none')}
>
Never
{'Never'}
</input>
</label>
</div>
@@ -162,25 +188,14 @@ export default class ChannelNotifications extends React.Component {
e.preventDefault();
}.bind(this);
let curChannel = ChannelStore.get(this.state.channelId);
let extraInfo = (
const extraInfo = (
<span>
These settings will override the global notification settings.
{'Selecting an option other than "Default" will override the global notification settings.'}
<br/>
Desktop notifications are available on Firefox, Safari, and Chrome.
{'Desktop notifications are available on Firefox, Safari, and Chrome.'}
</span>
);
if (curChannel && curChannel.display_name) {
extraInfo = (
<span>
These settings will override the global notification settings for the <b>{curChannel.display_name}</b> channel.
<br/>
Desktop notifications are available on Firefox, Safari, and Chrome.
</span>
);
}
return (
<SettingItemMax
title='Send desktop notifications'
@@ -194,7 +209,9 @@ export default class ChannelNotifications extends React.Component {
}
var describe;
if (this.state.notifyLevel === 'mention') {
if (this.state.notifyLevel === 'default') {
describe = `Global default (${globalNotifyLevelName})`;
} else if (this.state.notifyLevel === 'mention') {
describe = 'Only for mentions';
} else if (this.state.notifyLevel === 'all') {
describe = 'For all activity';

Просмотреть файл

@@ -200,13 +200,17 @@ export default class Sidebar extends React.Component {
}
var channel = ChannelStore.get(msg.channel_id);
var user = UserStore.getCurrentUser();
if (user.notify_props && ((user.notify_props.desktop === 'mention' && mentions.indexOf(user.id) === -1 && channel.type !== 'D') || user.notify_props.desktop === 'none')) {
return;
const user = UserStore.getCurrentUser();
const member = ChannelStore.getMember(msg.channel_id);
var notifyLevel = member.notify_level;
if (notifyLevel === 'default') {
notifyLevel = user.notify_props.desktop;
}
var member = ChannelStore.getMember(msg.channel_id);
if ((member.notify_level === 'mention' && mentions.indexOf(user.id) === -1) || member.notify_level === 'none' || member.notify_level === 'quiet') {
if (notifyLevel === 'none') {
return;
} else if (notifyLevel === 'mention' && mentions.indexOf(user.id) === -1 && channel.type !== 'D') {
return;
}

Просмотреть файл

@@ -17,7 +17,7 @@ function getNotificationsStateFromStores() {
if (user.notify_props && user.notify_props.desktop_sound) {
sound = user.notify_props.desktop_sound;
}
var desktop = 'all';
var desktop = 'default';
if (user.notify_props && user.notify_props.desktop) {
desktop = user.notify_props.desktop;
}