summaryrefslogtreecommitdiffstats
path: root/webapp/utils/async_client.jsx
diff options
context:
space:
mode:
authorenahum <nahumhbl@gmail.com>2016-12-19 10:05:46 -0300
committerJoram Wilander <jwawilander@gmail.com>2016-12-19 08:05:46 -0500
commit999d1553e1ce45adf58f6082b160bc1147dc592b (patch)
tree369a9b7f46dd44d136a79a050469429169433cec /webapp/utils/async_client.jsx
parent3ce2ce9dc882ed962dc3ce7550bdb07963f376b6 (diff)
downloadchat-999d1553e1ce45adf58f6082b160bc1147dc592b.tar.gz
chat-999d1553e1ce45adf58f6082b160bc1147dc592b.tar.bz2
chat-999d1553e1ce45adf58f6082b160bc1147dc592b.zip
PLT-4167 Team Sidebar (#4569)
* PLT-4167 Team Sidebar * Address feedback from PM * change route from my_members to members * bug fixes * Updating styles for teams sidebar (#4681) * Added PM changes * Fix corner cases * Addressing feedback * use two different endpoints * Bug fixes * Rename model and client functions, using preferences to store last team and channel viewed * Fix mobile notification count and closing the team sidebar * unit test, fixed bad merge and retrieve from cached when available * bug fixes * use id for last channel in preferences, query optimization * Updating multi team css (#4830)
Diffstat (limited to 'webapp/utils/async_client.jsx')
-rw-r--r--webapp/utils/async_client.jsx74
1 files changed, 73 insertions, 1 deletions
diff --git a/webapp/utils/async_client.jsx b/webapp/utils/async_client.jsx
index 9bcb4e07f..2d8e76fc2 100644
--- a/webapp/utils/async_client.jsx
+++ b/webapp/utils/async_client.jsx
@@ -166,12 +166,21 @@ export function updateLastViewedAt(id, active) {
channelId,
isActive,
() => {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_PREFERENCE,
+ preference: {
+ category: 'last',
+ name: TeamStore.getCurrentId(),
+ value: channelId
+ }
+ });
+
callTracker[`updateLastViewed${channelId}`] = 0;
ErrorStore.clearLastError();
},
(err) => {
callTracker[`updateLastViewed${channelId}`] = 0;
- var count = ErrorStore.getConnectionErrorCount();
+ const count = ErrorStore.getConnectionErrorCount();
ErrorStore.setConnectionErrorCount(count + 1);
dispatchError(err, 'updateLastViewedAt');
}
@@ -203,6 +212,14 @@ export function setLastViewedAt(lastViewedAt, id) {
channelId,
lastViewedAt,
() => {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_PREFERENCE,
+ preference: {
+ category: 'last',
+ name: TeamStore.getCurrentId(),
+ value: channelId
+ }
+ });
callTracker[`setLastViewedAt${channelId}${lastViewedAt}`] = 0;
ErrorStore.clearLastError();
},
@@ -847,6 +864,61 @@ export function getTeamMember(teamId, userId) {
);
}
+export function getMyTeamMembers() {
+ const callName = 'getMyTeamMembers';
+ if (isCallInProgress(callName)) {
+ return;
+ }
+
+ callTracker[callName] = utils.getTimestamp();
+ Client.getMyTeamMembers(
+ (data) => {
+ callTracker[callName] = 0;
+
+ const members = {};
+ for (const member of data) {
+ members[member.team_id] = member;
+ }
+
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_MY_TEAM_MEMBERS_UNREAD,
+ team_members: members
+ });
+ },
+ (err) => {
+ callTracker[callName] = 0;
+ dispatchError(err, 'getMyTeamMembers');
+ }
+ );
+}
+
+export function getMyTeamsUnread(teamId) {
+ const members = TeamStore.getMyTeamMembers();
+ if (members.length > 1) {
+ const callName = 'getMyTeamsUnread';
+ if (isCallInProgress(callName)) {
+ return;
+ }
+
+ callTracker[callName] = utils.getTimestamp();
+ Client.getMyTeamsUnread(
+ teamId,
+ (data) => {
+ callTracker[callName] = 0;
+
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_MY_TEAMS_UNREAD,
+ team_members: data
+ });
+ },
+ (err) => {
+ callTracker[callName] = 0;
+ dispatchError(err, 'getMyTeamsUnread');
+ }
+ );
+ }
+}
+
export function getTeamStats(teamId) {
const callName = `getTeamStats${teamId}`;
if (isCallInProgress(callName)) {