summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorBjörn Roland <bjoernr-de@users.noreply.github.com>2016-12-21 15:27:42 +0100
committerenahum <nahumhbl@gmail.com>2016-12-21 11:27:42 -0300
commitf0b74e78dde9a029e49e730d854b769a53756624 (patch)
treef330552202931e2e157a2f9a3124857c0386a413 /webapp
parent2c09582d89f6ff075fdfb8fce5f039b8ac5a920f (diff)
downloadchat-f0b74e78dde9a029e49e730d854b769a53756624.tar.gz
chat-f0b74e78dde9a029e49e730d854b769a53756624.tar.bz2
chat-f0b74e78dde9a029e49e730d854b769a53756624.zip
#4699 Move instances of Client.updateChannelNotifyProps() in components to an action (#4862)
Diffstat (limited to 'webapp')
-rw-r--r--webapp/actions/channel_actions.jsx15
-rw-r--r--webapp/components/channel_notifications_modal.jsx24
2 files changed, 28 insertions, 11 deletions
diff --git a/webapp/actions/channel_actions.jsx b/webapp/actions/channel_actions.jsx
index 12e58177d..ad2f315ee 100644
--- a/webapp/actions/channel_actions.jsx
+++ b/webapp/actions/channel_actions.jsx
@@ -260,3 +260,18 @@ export function autocompleteChannels(term, success, error) {
}
);
}
+
+export function updateChannelNotifyProps(data, success, error) {
+ Client.updateChannelNotifyProps(data,
+ () => {
+ if (success) {
+ success();
+ }
+ },
+ (err) => {
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
diff --git a/webapp/components/channel_notifications_modal.jsx b/webapp/components/channel_notifications_modal.jsx
index ff8ef94f7..58ab9143f 100644
--- a/webapp/components/channel_notifications_modal.jsx
+++ b/webapp/components/channel_notifications_modal.jsx
@@ -4,7 +4,6 @@
import SettingItemMin from 'components/setting_item_min.jsx';
import SettingItemMax from 'components/setting_item_max.jsx';
-import Client from 'client/web_client.jsx';
import ChannelStore from 'stores/channel_store.jsx';
import $ from 'jquery';
@@ -12,6 +11,8 @@ import React from 'react';
import {Modal} from 'react-bootstrap';
import {FormattedMessage} from 'react-intl';
+import {updateChannelNotifyProps} from 'actions/channel_actions.jsx';
+
export default class ChannelNotificationsModal extends React.Component {
constructor(props) {
super(props);
@@ -47,26 +48,28 @@ export default class ChannelNotificationsModal extends React.Component {
}
handleSubmitNotifyLevel() {
- var channelId = this.props.channel.id;
- var notifyLevel = this.state.notifyLevel;
+ const channelId = this.props.channel.id;
+ const notifyLevel = this.state.notifyLevel;
+ const currentUserId = this.props.currentUser.id;
if (this.props.channelMember.notify_props.desktop === notifyLevel) {
this.updateSection('');
return;
}
- var data = {};
- data.channel_id = channelId;
- data.user_id = this.props.currentUser.id;
- data.desktop = notifyLevel;
+ const data = {
+ channel_id: channelId,
+ user_id: currentUserId,
+ desktop: notifyLevel
+ };
- //TODO: This should be moved to event_helpers
- Client.updateChannelNotifyProps(data,
+ updateChannelNotifyProps(data,
() => {
// YUCK
var member = ChannelStore.getMyMember(channelId);
member.notify_props.desktop = notifyLevel;
ChannelStore.storeMyChannelMember(member);
+
this.updateSection('');
},
(err) => {
@@ -257,8 +260,7 @@ export default class ChannelNotificationsModal extends React.Component {
mark_unread: markUnreadLevel
};
- //TODO: This should be fixed, moved to actions
- Client.updateChannelNotifyProps(data,
+ updateChannelNotifyProps(data,
() => {
// Yuck...
var member = ChannelStore.getMyMember(channelId);