Improve Redux types part 1 (#25872)
* Always dispatch thunk actions instead of calling them * Properly dispatch actions in SwitchChannelProvider * Fix tests relying on bad types * Properly pass actions into ManageTokens * Make other logic changes to support new types * Do the big type migrations without any logic changes * Revert "Properly dispatch actions in SwitchChannelProvider" This reverts commit 28c8c7af2ef324c6814087a81baca66c60477daa. * Revert "Revert "Properly dispatch actions in SwitchChannelProvider"" This reverts commit 47115c5217ae90547040e7b7de32979a33f0845b.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
0a4e9eeb92
Коммит
978f335925
@@ -3,16 +3,14 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {ActionCreatorsMapObject, Dispatch} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {appBarEnabled, appsEnabled, getChannelHeaderAppBindings} from 'mattermost-redux/selectors/entities/apps';
|
||||
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import type {GenericAction} from 'mattermost-redux/types/actions';
|
||||
|
||||
import {handleBindingClick, openAppsModal, postEphemeralCallResponseForChannel} from 'actions/apps';
|
||||
import {getChannelHeaderPluginComponents, shouldShowAppBar} from 'selectors/plugins';
|
||||
|
||||
import type {HandleBindingClick, OpenAppsModal, PostEphemeralCallResponseForChannel} from 'types/apps';
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
import ChannelHeaderPlug from './channel_header_plug';
|
||||
@@ -30,15 +28,9 @@ function mapStateToProps(state: GlobalState) {
|
||||
};
|
||||
}
|
||||
|
||||
type Actions = {
|
||||
handleBindingClick: HandleBindingClick;
|
||||
postEphemeralCallResponseForChannel: PostEphemeralCallResponseForChannel;
|
||||
openAppsModal: OpenAppsModal;
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<any>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
handleBindingClick,
|
||||
postEphemeralCallResponseForChannel,
|
||||
openAppsModal,
|
||||
|
||||
@@ -68,7 +68,7 @@ export async function initializePlugins() {
|
||||
return;
|
||||
}
|
||||
|
||||
const {data, error} = await getPlugins()(store.dispatch);
|
||||
const {data, error} = await store.dispatch(getPlugins());
|
||||
if (error) {
|
||||
console.error(error); //eslint-disable-line no-console
|
||||
return;
|
||||
@@ -214,7 +214,7 @@ export async function loadPluginsIfNecessary() {
|
||||
|
||||
const oldManifests = store.getState().plugins.plugins;
|
||||
|
||||
const {error} = await getPlugins()(store.dispatch);
|
||||
const {error} = await store.dispatch(getPlugins());
|
||||
if (error) {
|
||||
console.error(error); //eslint-disable-line no-console
|
||||
return;
|
||||
|
||||
@@ -3,17 +3,15 @@
|
||||
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import type {ActionCreatorsMapObject, Dispatch} from 'redux';
|
||||
import type {Dispatch} from 'redux';
|
||||
|
||||
import {AppBindingLocations} from 'mattermost-redux/constants/apps';
|
||||
import {appsEnabled, makeAppBindingsSelector} from 'mattermost-redux/selectors/entities/apps';
|
||||
import {getMyCurrentChannelMembership} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import type {GenericAction} from 'mattermost-redux/types/actions';
|
||||
|
||||
import {handleBindingClick, openAppsModal, postEphemeralCallResponseForChannel} from 'actions/apps';
|
||||
|
||||
import type {HandleBindingClick, OpenAppsModal, PostEphemeralCallResponseForChannel} from 'types/apps';
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
import MobileChannelHeaderPlug from './mobile_channel_header_plug';
|
||||
@@ -31,15 +29,9 @@ function mapStateToProps(state: GlobalState) {
|
||||
};
|
||||
}
|
||||
|
||||
type Actions = {
|
||||
handleBindingClick: HandleBindingClick;
|
||||
postEphemeralCallResponseForChannel: PostEphemeralCallResponseForChannel;
|
||||
openAppsModal: OpenAppsModal;
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
|
||||
function mapDispatchToProps(dispatch: Dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators<ActionCreatorsMapObject<any>, Actions>({
|
||||
actions: bindActionCreators({
|
||||
handleBindingClick,
|
||||
postEphemeralCallResponseForChannel,
|
||||
openAppsModal,
|
||||
|
||||
Ссылка в новой задаче
Block a user