Files
mattermost-mobile/app/actions/views/emoji.js
Chris Duarte 8694f59e80 RN-335 Reaction shortcut (#920)
* RN-335 Reaction shortcut

* Review feedback
2017-09-20 11:08:17 -04:00

18 lines
664 B
JavaScript

// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {addReaction} from 'mattermost-redux/actions/posts';
import {getPostsInCurrentChannel, makeGetPostsForThread} from 'mattermost-redux/selectors/entities/posts';
const getPostsForThread = makeGetPostsForThread();
export function addReactionToLatestPost(emoji, rootId) {
return async (dispatch, getState) => {
const state = getState();
const posts = rootId ? getPostsForThread(state, {rootId}) : getPostsInCurrentChannel(state);
const lastPost = posts[0];
dispatch(addReaction(lastPost.id, emoji));
};
}