summaryrefslogtreecommitdiffstats
path: root/web/react/utils/client.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'web/react/utils/client.jsx')
-rw-r--r--web/react/utils/client.jsx64
1 files changed, 58 insertions, 6 deletions
diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx
index d27fe16cf..5d02a8c88 100644
--- a/web/react/utils/client.jsx
+++ b/web/react/utils/client.jsx
@@ -1,8 +1,8 @@
// See License.txt for license information.
-var BrowserStore = require('../stores/browser_store.jsx');
-var TeamStore = require('../stores/team_store.jsx');
-var ErrorStore = require('../stores/error_store.jsx');
+import BrowserStore from '../stores/browser_store.jsx';
+import TeamStore from '../stores/team_store.jsx';
+import ErrorStore from '../stores/error_store.jsx';
export function track(category, action, label, property, value) {
global.window.analytics.track(action, {category, label, property, value});
@@ -590,7 +590,12 @@ export function updateChannel(channel, success, error) {
track('api', 'api_channels_update');
}
-export function updateChannelHeader(data, success, error) {
+export function updateChannelHeader(channelId, header, success, error) {
+ const data = {
+ channel_id: channelId,
+ channel_header: header
+ };
+
$.ajax({
url: '/api/v1/channels/update_header',
dataType: 'json',
@@ -820,7 +825,37 @@ export function getPosts(channelId, since, success, error, complete) {
});
}
-export function getPost(channelId, postId, success, error) {
+export function getPostsBefore(channelId, post, offset, numPost, success, error, complete) {
+ $.ajax({
+ url: '/api/v1/channels/' + channelId + '/post/' + post + '/before/' + offset + '/' + numPost,
+ dataType: 'json',
+ type: 'GET',
+ ifModified: false,
+ success,
+ error: function onError(xhr, status, err) {
+ var e = handleError('getPostsBefore', xhr, status, err);
+ error(e);
+ },
+ complete: complete
+ });
+}
+
+export function getPostsAfter(channelId, post, offset, numPost, success, error, complete) {
+ $.ajax({
+ url: '/api/v1/channels/' + channelId + '/post/' + post + '/after/' + offset + '/' + numPost,
+ dataType: 'json',
+ type: 'GET',
+ ifModified: false,
+ success,
+ error: function onError(xhr, status, err) {
+ var e = handleError('getPostsAfter', xhr, status, err);
+ error(e);
+ },
+ complete: complete
+ });
+}
+
+export function getPost(channelId, postId, success, error, complete) {
$.ajax({
cache: false,
url: '/api/v1/channels/' + channelId + '/post/' + postId,
@@ -831,7 +866,24 @@ export function getPost(channelId, postId, success, error) {
error: function onError(xhr, status, err) {
var e = handleError('getPost', xhr, status, err);
error(e);
- }
+ },
+ complete
+ });
+}
+
+export function getPostById(postId, success, error, complete) {
+ $.ajax({
+ cache: false,
+ url: '/api/v1/posts/' + postId,
+ dataType: 'json',
+ type: 'GET',
+ ifModified: false,
+ success,
+ error: function onError(xhr, status, err) {
+ var e = handleError('getPostById', xhr, status, err);
+ error(e);
+ },
+ complete
});
}