import React from 'react'; import Flux from '../lib/flux'; import UserGuildSettingsStore from '../stores/UserGuildSettingsStore'; import Radio from './common/Radio'; import {UserNotificationSettings} from '../Constants'; import i18n from '../i18n'; import NotificationSettingsModalActionCreators from '../actions/NotificationSettingsModalActionCreators'; import ChannelMuteButton from './ChannelMuteButton'; import '../styles/channel_notification_settings.styl'; const ChannelNotificationSettings = React.createClass({ mixins: [Flux.StoreListenerMixin(UserGuildSettingsStore)], getStateFromStores() { return { messageNotifications: UserGuildSettingsStore.getChannelMessageNotifications( this.props.channel.getGuildId(), this.props.channel.id ), muted: UserGuildSettingsStore.isChannelMuted(this.props.channel.getGuildId(), this.props.channel.id), guildMessageNotifications: UserGuildSettingsStore.getMessageNotifications(this.props.channel.getGuildId()), }; }, handleRadioChange(key, e) { NotificationSettingsModalActionCreators.updateChannelOverrideSettings( this.props.channel.getGuildId(), this.props.channel.id, {[key]: parseInt(e.currentTarget.value, 10)} ); }, handleReset() { NotificationSettingsModalActionCreators.updateChannelOverrideSettings( this.props.channel.getGuildId(), this.props.channel.id, { // eslint-disable-next-line camelcase message_notifications: UserNotificationSettings.NULL, } ); }, messageNotificationsRadioOption(value) { const {messageNotifications, muted, guildMessageNotifications} = this.state; let checked = false; let isDefault = false; if (messageNotifications === UserNotificationSettings.NULL) { isDefault = guildMessageNotifications === value; } else { checked = messageNotifications === value; } return (