Improve Redux types part 5/Replace DispatchFunc (#26004)
* Remove non-functional code from Login component * Remove remaining usage of useDispatch<DispatchFunc> * Remove usage of DispatchFunc from actions/file_actions * actions/global_actions * Remove usage of DispatchFunc from actions/marketplace * Remove DispatchFunc from actions/post_actions * Remove DispatchFunc from actions/storage * Remove DispatchFunc from actions/user_actions * Remove DispatchFunc from actions/views/channel * Remove DispatchFunc from actions/views/channel_sidebar * Remove DispatchFunc from actions/views/create_comment * Remove DispatchFunc from actions/views/lhs.ts * Remove DispatchFunc from actions/views/rhs.ts * Remove DispatchFunc from actions/views/onboarding_tasks * Remove DispatchFunc from actions/views/root * Remove DispatchFunc from components/logged_in * Remove DispatchFunc from components/msg_typing * Remove DispatchFunc from components/permalink_view * Remove DispatchFunc from components/suggestion * Remove DispatchFunc from mattermost-redux/actions/posts * Remove DispatchFunc from mattermost-redux/actions/roles * Remove DispatchFunc from mattermost-redux/actions/threads * Remove DispatchFunc from mattermost-redux/actions/timezone * Remove DispatchFunc from plugins/products * Make DispatchFunc into Dispatch * Fix how dispatch is mocked in test for toggleSideBarRightMenuAction
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d8e11fe292
Коммит
8e165c7685
@@ -12,7 +12,7 @@ import {getCurrentChannel, getChannel as getChannelFromRedux} from 'mattermost-r
|
||||
import {isCollapsedThreadsEnabled} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {getCurrentTeam, getTeam} from 'mattermost-redux/selectors/entities/teams';
|
||||
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
|
||||
import type {DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions';
|
||||
import type {NewActionFuncAsync, ThunkActionFunc} from 'mattermost-redux/types/actions';
|
||||
import {getUserIdFromChannelName} from 'mattermost-redux/utils/channel_utils';
|
||||
import {isSystemAdmin} from 'mattermost-redux/utils/user_utils';
|
||||
|
||||
@@ -33,8 +33,8 @@ type Option = {
|
||||
skipRedirectReplyPermalink: boolean;
|
||||
}
|
||||
|
||||
function focusRootPost(post: Post, channel: Channel) {
|
||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
function focusRootPost(post: Post, channel: Channel): NewActionFuncAsync {
|
||||
return async (dispatch, getState) => {
|
||||
const postURL = getPostURL(getState() as GlobalState, post);
|
||||
|
||||
dispatch(selectChannel(channel.id));
|
||||
@@ -49,11 +49,11 @@ function focusRootPost(post: Post, channel: Channel) {
|
||||
};
|
||||
}
|
||||
|
||||
function focusReplyPost(post: Post, channel: Channel, teamId: string, returnTo: string, option: Option) {
|
||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
function focusReplyPost(post: Post, channel: Channel, teamId: string, returnTo: string, option: Option): NewActionFuncAsync {
|
||||
return async (dispatch, getState) => {
|
||||
const {data} = await dispatch(getPostThread(post.root_id));
|
||||
|
||||
if (data.first_inaccessible_post_time) {
|
||||
if (data!.first_inaccessible_post_time) {
|
||||
getHistory().replace(`/error?type=${ErrorPageTypes.CLOUD_ARCHIVED}&returnTo=${returnTo}`);
|
||||
return {data: false};
|
||||
}
|
||||
@@ -83,8 +83,8 @@ function focusReplyPost(post: Post, channel: Channel, teamId: string, returnTo:
|
||||
};
|
||||
}
|
||||
|
||||
export function focusPost(postId: string, returnTo = '', currentUserId: string, option: Option = {skipRedirectReplyPermalink: false}) {
|
||||
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
|
||||
export function focusPost(postId: string, returnTo = '', currentUserId: string, option: Option = {skipRedirectReplyPermalink: false}): ThunkActionFunc<Promise<void>> {
|
||||
return async (dispatch, getState) => {
|
||||
// Ignore if prompt is still visible
|
||||
if (privateChannelJoinPromptVisible) {
|
||||
return;
|
||||
@@ -108,7 +108,7 @@ export function focusPost(postId: string, returnTo = '', currentUserId: string,
|
||||
privateChannelJoinPromptVisible = true;
|
||||
const joinPromptResult = await dispatch(joinPrivateChannelPrompt(currentTeam, postInfo.channel_display_name));
|
||||
privateChannelJoinPromptVisible = false;
|
||||
if ('data' in joinPromptResult && !joinPromptResult.data.join) {
|
||||
if ('data' in joinPromptResult && !joinPromptResult.data!.join) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -155,7 +155,7 @@ export function focusPost(postId: string, returnTo = '', currentUserId: string,
|
||||
|
||||
const membership = await dispatch(getChannelMember(channel.id, currentUserId));
|
||||
if ('data' in membership) {
|
||||
myMember = membership.data;
|
||||
myMember = membership.data!;
|
||||
}
|
||||
|
||||
if (!myMember) {
|
||||
|
||||
Ссылка в новой задаче
Block a user