summaryrefslogtreecommitdiffstats
path: root/web/react/utils/async_client.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'web/react/utils/async_client.jsx')
-rw-r--r--web/react/utils/async_client.jsx52
1 files changed, 52 insertions, 0 deletions
diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx
index a903f055b..1bf8a6fee 100644
--- a/web/react/utils/async_client.jsx
+++ b/web/react/utils/async_client.jsx
@@ -637,3 +637,55 @@ export function getMyTeam() {
}
);
}
+
+export function getDirectChannelPreferences() {
+ if (isCallInProgress('getDirectChannelPreferences')) {
+ return;
+ }
+
+ callTracker.getDirectChannelPreferences = utils.getTimestamp();
+ client.getPreferenceCategory(
+ Constants.Preferences.CATEGORY_DIRECT_CHANNEL_SHOW,
+ (data, textStatus, xhr) => {
+ callTracker.getDirectChannelPreferences = 0;
+
+ if (xhr.status === 304 || !data) {
+ return;
+ }
+
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECIEVED_PREFERENCES,
+ preferences: data
+ });
+ },
+ (err) => {
+ callTracker.getDirectChannelPreferences = 0;
+ dispatchError(err, 'getDirectChannelPreferences');
+ }
+ );
+}
+
+export function savePreferences(preferences, success, error) {
+ client.savePreferences(
+ preferences,
+ (data, textStatus, xhr) => {
+ if (xhr.status !== 304) {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECIEVED_PREFERENCES,
+ preferences
+ });
+ }
+
+ if (success) {
+ success(data);
+ }
+ },
+ (err) => {
+ dispatchError(err, 'savePreferences');
+
+ if (error) {
+ error();
+ }
+ }
+ );
+}