summaryrefslogtreecommitdiffstats
path: root/web/react/utils
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-10-02 14:25:55 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-10-13 09:42:24 -0400
commited31538893ad2790de46ace7eeac5c1aa015a7f1 (patch)
tree3db603d322390b4d534501dd46932f96ef279ce3 /web/react/utils
parent7d03c24b44a2f4eba86adf86954280fa73e726e4 (diff)
downloadchat-ed31538893ad2790de46ace7eeac5c1aa015a7f1.tar.gz
chat-ed31538893ad2790de46ace7eeac5c1aa015a7f1.tar.bz2
chat-ed31538893ad2790de46ace7eeac5c1aa015a7f1.zip
Changed direct messages channels so users can show/hide them
Diffstat (limited to 'web/react/utils')
-rw-r--r--web/react/utils/async_client.jsx24
-rw-r--r--web/react/utils/client.jsx13
2 files changed, 37 insertions, 0 deletions
diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx
index 3f084578a..d665dfc94 100644
--- a/web/react/utils/async_client.jsx
+++ b/web/react/utils/async_client.jsx
@@ -666,3 +666,27 @@ export function getDirectChannels() {
);
}
+export function setPreferences(preferences, success, error) {
+ client.setPreferences(
+ preferences,
+ (data, textStatus, xhr) => {
+ if (xhr.status !== 304) {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECIEVED_PREFERENCES,
+ preferences
+ });
+ }
+
+ if (success) {
+ success(data);
+ }
+ },
+ (err) => {
+ dispatchError(err, 'setPreferences');
+
+ if (error) {
+ error();
+ }
+ }
+ );
+}
diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx
index f1827f296..2134dc0f5 100644
--- a/web/react/utils/client.jsx
+++ b/web/react/utils/client.jsx
@@ -1155,3 +1155,16 @@ export function getPreferencesByName(category, name, success, error) {
});
}
+export function setPreferences(preferences, success, error) {
+ $.ajax({
+ url: '/api/v1/preferences/set',
+ dataType: 'json',
+ type: 'POST',
+ data: JSON.stringify(preferences),
+ success,
+ error: (xhr, status, err) => {
+ var e = handleError('setPreferences', xhr, status, err);
+ error(e);
+ }
+ });
+}