summaryrefslogtreecommitdiffstats
path: root/webapp/actions
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-04-17 15:08:56 -0400
committerChristopher Speller <crspeller@gmail.com>2017-04-17 15:08:56 -0400
commit92d8fa4aa8af170d0018baed94a8787d06297e44 (patch)
treedc5000a3584952c797c03bf4331282a5e1536848 /webapp/actions
parent742bab6429aeb1b581275da3c06af99fe293baab (diff)
parent30974533941e73f102505d07badf538cfdbbf3fc (diff)
downloadchat-92d8fa4aa8af170d0018baed94a8787d06297e44.tar.gz
chat-92d8fa4aa8af170d0018baed94a8787d06297e44.tar.bz2
chat-92d8fa4aa8af170d0018baed94a8787d06297e44.zip
Merge branch 'release-3.8'
Diffstat (limited to 'webapp/actions')
-rw-r--r--webapp/actions/channel_actions.jsx2
-rw-r--r--webapp/actions/notification_actions.jsx6
-rw-r--r--webapp/actions/post_actions.jsx23
-rw-r--r--webapp/actions/user_actions.jsx61
4 files changed, 67 insertions, 25 deletions
diff --git a/webapp/actions/channel_actions.jsx b/webapp/actions/channel_actions.jsx
index 3f4ab210d..d441a0e94 100644
--- a/webapp/actions/channel_actions.jsx
+++ b/webapp/actions/channel_actions.jsx
@@ -300,7 +300,7 @@ export function loadDMsAndGMsForUnreads() {
if (unreads[id].msgs > 0 || unreads[id].mentions > 0) {
const channel = ChannelStore.get(id);
if (channel && channel.type === Constants.DM_CHANNEL) {
- loadNewDMIfNeeded(Utils.getUserIdFromChannelName(channel));
+ loadNewDMIfNeeded(channel.id);
} else if (channel && channel.type === Constants.GM_CHANNEL) {
loadNewGMIfNeeded(channel.id);
}
diff --git a/webapp/actions/notification_actions.jsx b/webapp/actions/notification_actions.jsx
index ecf301ed8..82a68c452 100644
--- a/webapp/actions/notification_actions.jsx
+++ b/webapp/actions/notification_actions.jsx
@@ -66,7 +66,11 @@ export function sendDesktopNotification(post, msgProps) {
}
if (title === '') {
- title = msgProps.channel_display_name;
+ if (msgProps.channel_type === Constants.DM_CHANNEL) {
+ title = Utils.localizeMessage('notification.dm', 'Direct Message');
+ } else {
+ title = msgProps.channel_display_name;
+ }
}
let notifyText = post.message.replace(/\n+/g, ' ');
diff --git a/webapp/actions/post_actions.jsx b/webapp/actions/post_actions.jsx
index e6daecf31..5319a00c6 100644
--- a/webapp/actions/post_actions.jsx
+++ b/webapp/actions/post_actions.jsx
@@ -20,24 +20,29 @@ const ActionTypes = Constants.ActionTypes;
const Preferences = Constants.Preferences;
export function handleNewPost(post, msg) {
- let websocketMessageProps = null;
+ let websocketMessageProps = {};
if (msg) {
websocketMessageProps = msg.data;
}
- if (msg && msg.data) {
- if (msg.data.channel_type === Constants.DM_CHANNEL) {
- loadNewDMIfNeeded(post.user_id);
- } else if (msg.data.channel_type === Constants.GM_CHANNEL) {
- loadNewGMIfNeeded(post.channel_id, post.user_id);
- }
- }
-
if (ChannelStore.getMyMember(post.channel_id)) {
completePostReceive(post, websocketMessageProps);
} else {
+ // This API call requires any real team id in API v3, so set one if we don't already have one
+ if (!Client.teamId && msg && msg.data) {
+ Client.setTeamId(msg.data.team_id);
+ }
+
AsyncClient.getChannelMember(post.channel_id, UserStore.getCurrentId()).then(() => completePostReceive(post, websocketMessageProps));
}
+
+ if (msg && msg.data) {
+ if (msg.data.channel_type === Constants.DM_CHANNEL) {
+ loadNewDMIfNeeded(post.channel_id);
+ } else if (msg.data.channel_type === Constants.GM_CHANNEL) {
+ loadNewGMIfNeeded(post.channel_id);
+ }
+ }
}
function completePostReceive(post, websocketMessageProps) {
diff --git a/webapp/actions/user_actions.jsx b/webapp/actions/user_actions.jsx
index b56d5ff45..9f9987cdd 100644
--- a/webapp/actions/user_actions.jsx
+++ b/webapp/actions/user_actions.jsx
@@ -11,7 +11,7 @@ import ChannelStore from 'stores/channel_store.jsx';
import {getChannelMembersForUserIds} from 'actions/channel_actions.jsx';
import {loadStatusesForProfilesList, loadStatusesForProfilesMap} from 'actions/status_actions.jsx';
-import {getDirectChannelName} from 'utils/utils.jsx';
+import {getDirectChannelName, getUserIdFromChannelName} from 'utils/utils.jsx';
import * as AsyncClient from 'utils/async_client.jsx';
import Client from 'client/web_client.jsx';
@@ -255,24 +255,45 @@ function populateChannelWithProfiles(channelId, userIds) {
UserStore.emitInChannelChange();
}
-export function loadNewDMIfNeeded(userId) {
- if (userId === UserStore.getCurrentId()) {
- return;
- }
+export function loadNewDMIfNeeded(channelId) {
+ function checkPreference(channel) {
+ const userId = getUserIdFromChannelName(channel);
+
+ if (!userId) {
+ return;
+ }
- const pref = PreferenceStore.getBool(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, false);
- if (pref === false) {
- PreferenceStore.setPreference(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, 'true');
- AsyncClient.savePreference(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, 'true');
- loadProfilesForDM();
+ const pref = PreferenceStore.getBool(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, false);
+ if (pref === false) {
+ PreferenceStore.setPreference(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, 'true');
+ AsyncClient.savePreference(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, userId, 'true');
+ loadProfilesForDM();
+ }
}
-}
-export function loadNewGMIfNeeded(channelId, userId) {
- if (userId === UserStore.getCurrentId()) {
- return;
+ const channel = ChannelStore.get(channelId);
+ if (channel) {
+ checkPreference(channel);
+ } else {
+ Client.getChannel(
+ channelId,
+ (data) => {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_CHANNEL,
+ channel: data.channel,
+ member: data.member
+ });
+
+ checkPreference(data.channel);
+ },
+ (err) => {
+ AsyncClient.dispatchError(err, 'getChannel');
+ }
+ );
}
+}
+export function loadNewGMIfNeeded(channelId) {
function checkPreference() {
const pref = PreferenceStore.getBool(Preferences.CATEGORY_GROUP_CHANNEL_SHOW, channelId, false);
if (pref === false) {
@@ -932,3 +953,15 @@ export function getMissingProfiles(ids, success, error) {
AsyncClient.getProfilesByIds(missingIds, success, error);
}
+
+export function loadMyTeamMembers() {
+ Client.getMyTeamMembers((data) => {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_MY_TEAM_MEMBERS,
+ team_members: data
+ });
+ AsyncClient.getMyTeamsUnread();
+ }, (err) => {
+ AsyncClient.dispatchError(err, 'getMyTeamMembers');
+ });
+}