summaryrefslogtreecommitdiffstats
path: root/webapp/utils/async_client.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/utils/async_client.jsx')
-rw-r--r--webapp/utils/async_client.jsx60
1 files changed, 60 insertions, 0 deletions
diff --git a/webapp/utils/async_client.jsx b/webapp/utils/async_client.jsx
index e55742140..b31a2a6b9 100644
--- a/webapp/utils/async_client.jsx
+++ b/webapp/utils/async_client.jsx
@@ -145,6 +145,43 @@ export function updateLastViewedAt(id) {
);
}
+export function setLastViewedAt(lastViewedAt, id) {
+ let channelId;
+ if (id) {
+ channelId = id;
+ } else {
+ channelId = ChannelStore.getCurrentId();
+ }
+
+ if (channelId == null) {
+ return;
+ }
+
+ if (lastViewedAt == null) {
+ return;
+ }
+
+ if (isCallInProgress(`setLastViewedAt${channelId}${lastViewedAt}`)) {
+ return;
+ }
+
+ callTracker[`setLastViewedAt${channelId}${lastViewedAt}`] = utils.getTimestamp();
+ Client.setLastViewedAt(
+ channelId,
+ lastViewedAt,
+ () => {
+ callTracker.setLastViewedAt = 0;
+ ErrorStore.clearLastError();
+ },
+ (err) => {
+ callTracker.setLastViewedAt = 0;
+ var count = ErrorStore.getConnectionErrorCount();
+ ErrorStore.setConnectionErrorCount(count + 1);
+ dispatchError(err, 'setLastViewedAt');
+ }
+ );
+}
+
export function getMoreChannels(force) {
if (isCallInProgress('getMoreChannels')) {
return;
@@ -815,6 +852,29 @@ export function savePreferences(preferences, success, error) {
);
}
+export function deletePreferences(preferences, success, error) {
+ Client.deletePreferences(
+ preferences,
+ (data) => {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.DELETED_PREFERENCES,
+ preferences
+ });
+
+ if (success) {
+ success(data);
+ }
+ },
+ (err) => {
+ dispatchError(err, 'deletePreferences');
+
+ if (error) {
+ error();
+ }
+ }
+ );
+}
+
export function getSuggestedCommands(command, suggestionId, component) {
Client.listCommands(
(data) => {