* MM-13957 Reorganize post actions (#2553) * MM-13957 Reorganize post actions * Update mattermost-redux * Update mattermost-redux * Update package-lock.json to resolve build issues * MM-13958/MM-13959 Make postsInChannel into a sparse array (#2600) * MM-13960 Re-add combined system messages (#2637) * MM-13960 Re-add combined system messages * Pass entire post to PostOptions * Update mattermost-redux * Update mattermost-redux * Address feedback * Update mattermost-redux
60 lines
1.6 KiB
JavaScript
60 lines
1.6 KiB
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {Posts} from 'mattermost-redux/constants';
|
|
import {doPostAction, receivedNewPost} from 'mattermost-redux/actions/posts';
|
|
|
|
import {ViewTypes} from 'app/constants';
|
|
|
|
import {generateId} from 'app/utils/file';
|
|
|
|
export function sendAddToChannelEphemeralPost(user, addedUsername, message, channelId, postRootId = '') {
|
|
return async (dispatch) => {
|
|
const timestamp = Date.now();
|
|
const post = {
|
|
id: generateId(),
|
|
user_id: user.id,
|
|
channel_id: channelId,
|
|
message,
|
|
type: Posts.POST_TYPES.EPHEMERAL_ADD_TO_CHANNEL,
|
|
create_at: timestamp,
|
|
update_at: timestamp,
|
|
root_id: postRootId,
|
|
parent_id: postRootId,
|
|
props: {
|
|
username: user.username,
|
|
addedUsername,
|
|
},
|
|
};
|
|
|
|
dispatch(receivedNewPost(post));
|
|
};
|
|
}
|
|
|
|
export function setAutocompleteSelector(dataSource, onSelect, options) {
|
|
return {
|
|
type: ViewTypes.SELECTED_ACTION_MENU,
|
|
data: {
|
|
dataSource,
|
|
onSelect,
|
|
options,
|
|
},
|
|
};
|
|
}
|
|
|
|
export function selectAttachmentMenuAction(postId, actionId, text, value) {
|
|
return (dispatch) => {
|
|
dispatch({
|
|
type: ViewTypes.SUBMIT_ATTACHMENT_MENU_ACTION,
|
|
postId,
|
|
data: {
|
|
[actionId]: {
|
|
text,
|
|
value,
|
|
},
|
|
},
|
|
});
|
|
|
|
dispatch(doPostAction(postId, actionId, value));
|
|
};
|
|
}
|