Files
mattermost-mobile/app/components/embedded_bindings/button_binding/index.ts
Mattermost Build c9e6cd8073 Post app call response ephemeral messages as bot (#5256) (#5265)
* post app call response ephemeral messages as bot

* add check for isBot

* add SendEphemeralPost func type

* snapshot

(cherry picked from commit f766f47358)

Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com>
2021-04-02 14:10:14 -04:00

50 lines
1.7 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {ActionCreatorsMapObject, bindActionCreators, Dispatch} from 'redux';
import {connect} from 'react-redux';
import {getTheme} from '@mm-redux/selectors/entities/preferences';
import {GlobalState} from '@mm-redux/types/store';
import {ActionFunc, ActionResult, GenericAction} from '@mm-redux/types/actions';
import {AppCallRequest, AppCallResponse, AppCallType} from '@mm-redux/types/apps';
import {doAppCall} from '@actions/apps';
import {getPost} from '@mm-redux/selectors/entities/posts';
import ButtonBinding from './button_binding';
import {getChannel} from '@mm-redux/actions/channels';
import {sendEphemeralPost} from '@actions/views/post';
import {getCurrentTeamId} from '@mm-redux/selectors/entities/teams';
import {SendEphemeralPost} from 'types/actions/posts';
type OwnProps = {
postId: string;
}
function mapStateToProps(state: GlobalState, ownProps: OwnProps) {
return {
theme: getTheme(state),
post: getPost(state, ownProps.postId),
currentTeamID: getCurrentTeamId(state),
};
}
type Actions = {
doAppCall: (call: AppCallRequest, type: AppCallType, intl: any) => Promise<{data?: AppCallResponse, error?: AppCallResponse}>;
getChannel: (channelId: string) => Promise<ActionResult>;
sendEphemeralPost: SendEphemeralPost;
}
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
return {
actions: bindActionCreators<ActionCreatorsMapObject<ActionFunc>, Actions>({
doAppCall,
getChannel,
sendEphemeralPost,
}, dispatch),
};
}
export default connect(mapStateToProps, mapDispatchToProps)(ButtonBinding);