summaryrefslogtreecommitdiffstats
path: root/webapp/actions
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-07-18 15:45:23 -0700
committerChristopher Speller <crspeller@gmail.com>2017-07-18 15:45:23 -0700
commit97f34e483b0fa8b2a8cfe75b72168cfa38cc9d80 (patch)
treeec2d68077dd2b12de3173871622f3ec2a2b61d35 /webapp/actions
parent21a3219b9b1df033635631afa751742bd4c56ea0 (diff)
parenta350f4dc0754e1aeabb64bd712ce05f7c59cfa60 (diff)
downloadchat-97f34e483b0fa8b2a8cfe75b72168cfa38cc9d80.tar.gz
chat-97f34e483b0fa8b2a8cfe75b72168cfa38cc9d80.tar.bz2
chat-97f34e483b0fa8b2a8cfe75b72168cfa38cc9d80.zip
Merge branch 'release-4.0'
Diffstat (limited to 'webapp/actions')
-rw-r--r--webapp/actions/emoji_actions.jsx2
-rw-r--r--webapp/actions/global_actions.jsx24
-rw-r--r--webapp/actions/post_actions.jsx71
-rw-r--r--webapp/actions/status_actions.jsx16
-rw-r--r--webapp/actions/websocket_actions.jsx15
5 files changed, 79 insertions, 49 deletions
diff --git a/webapp/actions/emoji_actions.jsx b/webapp/actions/emoji_actions.jsx
index a6323449e..1c0d8b5ea 100644
--- a/webapp/actions/emoji_actions.jsx
+++ b/webapp/actions/emoji_actions.jsx
@@ -13,7 +13,7 @@ import {getProfilesByIds} from 'mattermost-redux/actions/users';
import * as EmojiActions from 'mattermost-redux/actions/emojis';
export async function loadEmoji(getProfiles = true) {
- const data = await EmojiActions.getAllCustomEmojis(10000)(dispatch, getState);
+ const data = await EmojiActions.getAllCustomEmojis()(dispatch, getState);
if (data && getProfiles) {
loadProfilesForEmoji(data);
diff --git a/webapp/actions/global_actions.jsx b/webapp/actions/global_actions.jsx
index 33a1c8432..e37e702a2 100644
--- a/webapp/actions/global_actions.jsx
+++ b/webapp/actions/global_actions.jsx
@@ -332,13 +332,6 @@ export function emitPreferencesDeletedEvent(preferences) {
});
}
-export function emitRemovePost(post) {
- AppDispatcher.handleViewAction({
- type: Constants.ActionTypes.REMOVE_POST,
- post
- });
-}
-
export function sendEphemeralPost(message, channelId) {
const timestamp = Utils.getTimestamp();
const post = {
@@ -497,6 +490,23 @@ export function toggleSideBarAction(visible) {
}
}
+export function toggleSideBarRightMenuAction() {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_SEARCH,
+ results: null
+ });
+
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_POST_SELECTED,
+ postId: null
+ });
+
+ document.querySelector('.app__body .inner-wrap').classList.remove('move--right', 'move--left', 'move--left-small');
+ document.querySelector('.app__body .sidebar--left').classList.remove('move--right');
+ document.querySelector('.app__body .sidebar--right').classList.remove('move--left');
+ document.querySelector('.app__body .sidebar--menu').classList.remove('move--left');
+}
+
export function emitBrowserFocus(focus) {
AppDispatcher.handleViewAction({
type: ActionTypes.BROWSER_CHANGE_FOCUS,
diff --git a/webapp/actions/post_actions.jsx b/webapp/actions/post_actions.jsx
index 43204a543..09cc14e40 100644
--- a/webapp/actions/post_actions.jsx
+++ b/webapp/actions/post_actions.jsx
@@ -14,12 +14,13 @@ import {sendDesktopNotification} from 'actions/notification_actions.jsx';
import Constants from 'utils/constants.jsx';
const ActionTypes = Constants.ActionTypes;
+import {browserHistory} from 'react-router/es6';
+
// Redux actions
import store from 'stores/redux_store.jsx';
const dispatch = store.dispatch;
const getState = store.getState;
-import {getProfilesByIds} from 'mattermost-redux/actions/users';
import * as PostActions from 'mattermost-redux/actions/posts';
import {getMyChannelMember} from 'mattermost-redux/actions/channels';
@@ -55,7 +56,7 @@ function completePostReceive(post, websocketMessageProps) {
PostActions.getPostThread(post.root_id)(dispatch, getState).then(
(data) => {
dispatchPostActions(post, websocketMessageProps);
- loadProfilesForPosts(data.posts);
+ PostActions.getProfilesAndStatusesForPosts(data.posts, dispatch, getState);
}
);
@@ -123,7 +124,7 @@ export function getFlaggedPosts() {
is_pinned_posts: false
});
- loadProfilesForPosts(data.posts);
+ PostActions.getProfilesAndStatusesForPosts(data.posts, dispatch, getState);
}
).catch(
() => {} //eslint-disable-line no-empty-function
@@ -147,34 +148,13 @@ export function getPinnedPosts(channelId = ChannelStore.getCurrentId()) {
is_pinned_posts: true
});
- loadProfilesForPosts(data.posts);
+ PostActions.getProfilesAndStatusesForPosts(data.posts, dispatch, getState);
}
).catch(
() => {} //eslint-disable-line no-empty-function
);
}
-export function loadProfilesForPosts(posts) {
- const profilesToLoad = {};
- for (const pid in posts) {
- if (!posts.hasOwnProperty(pid)) {
- continue;
- }
-
- const post = posts[pid];
- if (!UserStore.hasProfile(post.user_id)) {
- profilesToLoad[post.user_id] = true;
- }
- }
-
- const list = Object.keys(profilesToLoad);
- if (list.length === 0) {
- return;
- }
-
- getProfilesByIds(list)(dispatch, getState);
-}
-
export function addReaction(channelId, postId, emojiName) {
PostActions.addReaction(postId, emojiName)(dispatch, getState);
}
@@ -202,6 +182,13 @@ export function updatePost(post, success) {
(data) => {
if (data && success) {
success();
+ } else {
+ const serverError = getState().requests.posts.editPost.error;
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_ERROR,
+ err: {id: serverError.server_error_id, ...serverError},
+ method: 'editPost'
+ });
}
}
);
@@ -236,6 +223,18 @@ export function deletePost(channelId, post, success) {
data: post
});
+ // Needed for search store
+ AppDispatcher.handleViewAction({
+ type: Constants.ActionTypes.REMOVE_POST,
+ post
+ });
+
+ const {focusedPostId} = getState().views.channel;
+ const channel = getState().entities.channels.channels[post.channel_id];
+ if (post.id === focusedPostId && channel) {
+ browserHistory.push(TeamStore.getCurrentTeamRelativeUrl() + '/channels/' + channel.name);
+ }
+
if (success) {
success();
}
@@ -252,7 +251,7 @@ export function performSearch(terms, isMentionSearch, success, error) {
is_mention_search: isMentionSearch
});
- loadProfilesForPosts(data.posts);
+ PostActions.getProfilesAndStatusesForPosts(data.posts, dispatch, getState);
if (success) {
success(data);
@@ -321,3 +320,23 @@ export function searchForTerm(term) {
do_search: true
});
}
+
+export function pinPost(postId) {
+ return async (doDispatch, doGetState) => {
+ await PostActions.pinPost(postId)(doDispatch, doGetState);
+
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_POST_PINNED
+ });
+ };
+}
+
+export function unpinPost(postId) {
+ return async (doDispatch, doGetState) => {
+ await PostActions.unpinPost(postId)(doDispatch, doGetState);
+
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_POST_UNPINNED
+ });
+ };
+}
diff --git a/webapp/actions/status_actions.jsx b/webapp/actions/status_actions.jsx
index 066a89254..e8559bd65 100644
--- a/webapp/actions/status_actions.jsx
+++ b/webapp/actions/status_actions.jsx
@@ -54,16 +54,9 @@ export function loadStatusesForChannelAndSidebar() {
const statusesToLoad = {};
const channelId = ChannelStore.getCurrentId();
- const postList = PostStore.getVisiblePosts(channelId);
- if (postList && postList.posts) {
- for (const pid in postList.posts) {
- if (!postList.posts.hasOwnProperty(pid)) {
- continue;
- }
-
- const post = postList.posts[pid];
- statusesToLoad[post.user_id] = true;
- }
+ const posts = PostStore.getVisiblePosts(channelId) || [];
+ for (const post of posts) {
+ statusesToLoad[post.user_id] = true;
}
const dmPrefs = PreferenceStore.getCategory(Preferences.CATEGORY_DIRECT_CHANNEL_SHOW);
@@ -74,6 +67,9 @@ export function loadStatusesForChannelAndSidebar() {
}
}
+ const {currentUserId} = getState().entities.users;
+ statusesToLoad[currentUserId] = true;
+
loadStatusesByIds(Object.keys(statusesToLoad));
}
diff --git a/webapp/actions/websocket_actions.jsx b/webapp/actions/websocket_actions.jsx
index dec3edd12..184013179 100644
--- a/webapp/actions/websocket_actions.jsx
+++ b/webapp/actions/websocket_actions.jsx
@@ -2,6 +2,7 @@
// See License.txt for license information.
import $ from 'jquery';
+import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import UserStore from 'stores/user_store.jsx';
import TeamStore from 'stores/team_store.jsx';
@@ -15,7 +16,7 @@ import WebSocketClient from 'client/web_websocket_client.jsx';
import * as WebrtcActions from './webrtc_actions.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
-import {handleNewPost, loadProfilesForPosts} from 'actions/post_actions.jsx';
+import {handleNewPost} from 'actions/post_actions.jsx';
import {loadProfilesForSidebar} from 'actions/user_actions.jsx';
import {loadChannelsForCurrentUser} from 'actions/channel_actions.jsx';
import * as StatusActions from 'actions/status_actions.jsx';
@@ -34,7 +35,7 @@ import {getSiteURL} from 'utils/url.jsx';
import * as TeamActions from 'mattermost-redux/actions/teams';
import {viewChannel, getChannelAndMyMember, getChannelStats} from 'mattermost-redux/actions/channels';
-import {getPosts} from 'mattermost-redux/actions/posts';
+import {getPosts, getProfilesAndStatusesForPosts} from 'mattermost-redux/actions/posts';
import {setServerVersion} from 'mattermost-redux/actions/general';
import {ChannelTypes, TeamTypes, UserTypes, PostTypes, EmojiTypes} from 'mattermost-redux/action_types';
@@ -242,9 +243,7 @@ function handleNewPostEvent(msg) {
const post = JSON.parse(msg.data.post);
handleNewPost(post, msg);
- const posts = {};
- posts[post.id] = post;
- loadProfilesForPosts(posts);
+ getProfilesAndStatusesForPosts([post], dispatch, getState);
if (post.user_id !== UserStore.getCurrentId()) {
UserStore.setStatus(post.user_id, UserStatuses.ONLINE);
@@ -267,6 +266,12 @@ function handlePostEditEvent(msg) {
function handlePostDeleteEvent(msg) {
const post = JSON.parse(msg.data.post);
dispatch({type: PostTypes.POST_DELETED, data: post});
+
+ // Needed for search store
+ AppDispatcher.handleViewAction({
+ type: Constants.ActionTypes.POST_DELETED,
+ post
+ });
}
async function handleTeamAddedEvent(msg) {