[Refactoring] Add typing for openChat
This commit is contained in:
parent
4f3c7a1a69
commit
a348fda4dd
@ -68,7 +68,11 @@ addActionHandler('preloadTopChatMessages', async (global, actions) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
addActionHandler('openChat', (global, actions, payload) => {
|
addActionHandler('openChat', (global, actions, payload) => {
|
||||||
const { id, threadId } = payload!;
|
const { id, threadId = MAIN_THREAD_ID } = payload;
|
||||||
|
if (!id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const { currentUserId } = global;
|
const { currentUserId } = global;
|
||||||
const chat = selectChat(global, id);
|
const chat = selectChat(global, id);
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
import { addActionHandler, setGlobal } from '../../index';
|
import { addActionHandler, setGlobal } from '../../index';
|
||||||
|
|
||||||
|
import { MAIN_THREAD_ID } from '../../../api/types';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
exitMessageSelectMode, replaceThreadParam, updateCurrentMessageList,
|
exitMessageSelectMode, replaceThreadParam, updateCurrentMessageList,
|
||||||
} from '../../reducers';
|
} from '../../reducers';
|
||||||
@ -8,8 +10,11 @@ import { closeLocalTextSearch } from './localSearch';
|
|||||||
|
|
||||||
addActionHandler('openChat', (global, actions, payload) => {
|
addActionHandler('openChat', (global, actions, payload) => {
|
||||||
const {
|
const {
|
||||||
id, threadId = -1, type = 'thread', shouldReplaceHistory = false,
|
id,
|
||||||
} = payload!;
|
threadId = MAIN_THREAD_ID,
|
||||||
|
type = 'thread',
|
||||||
|
shouldReplaceHistory = false,
|
||||||
|
} = payload;
|
||||||
|
|
||||||
const currentMessageList = selectCurrentMessageList(global);
|
const currentMessageList = selectCurrentMessageList(global);
|
||||||
|
|
||||||
@ -19,7 +24,10 @@ addActionHandler('openChat', (global, actions, payload) => {
|
|||||||
|| currentMessageList.threadId !== threadId
|
|| currentMessageList.threadId !== threadId
|
||||||
|| currentMessageList.type !== type
|
|| currentMessageList.type !== type
|
||||||
)) {
|
)) {
|
||||||
global = replaceThreadParam(global, id, threadId, 'replyStack', []);
|
if (id) {
|
||||||
|
global = replaceThreadParam(global, id, threadId, 'replyStack', []);
|
||||||
|
}
|
||||||
|
|
||||||
global = exitMessageSelectMode(global);
|
global = exitMessageSelectMode(global);
|
||||||
global = closeLocalTextSearch(global);
|
global = closeLocalTextSearch(global);
|
||||||
|
|
||||||
|
|||||||
@ -509,6 +509,12 @@ export type GlobalState = {
|
|||||||
|
|
||||||
export interface ActionPayloads {
|
export interface ActionPayloads {
|
||||||
apiUpdate: ApiUpdate;
|
apiUpdate: ApiUpdate;
|
||||||
|
openChat: {
|
||||||
|
id: string | undefined;
|
||||||
|
threadId?: number;
|
||||||
|
type?: MessageListType;
|
||||||
|
shouldReplaceHistory?: boolean;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export type NonTypedActionNames = (
|
export type NonTypedActionNames = (
|
||||||
@ -525,7 +531,7 @@ export type NonTypedActionNames = (
|
|||||||
'setAuthPhoneNumber' | 'setAuthCode' | 'setAuthPassword' | 'signUp' | 'returnToAuthPhoneNumber' | 'signOut' |
|
'setAuthPhoneNumber' | 'setAuthCode' | 'setAuthPassword' | 'signUp' | 'returnToAuthPhoneNumber' | 'signOut' |
|
||||||
'setAuthRememberMe' | 'clearAuthError' | 'uploadProfilePhoto' | 'goToAuthQrCode' | 'clearCache' |
|
'setAuthRememberMe' | 'clearAuthError' | 'uploadProfilePhoto' | 'goToAuthQrCode' | 'clearCache' |
|
||||||
// chats
|
// chats
|
||||||
'preloadTopChatMessages' | 'loadAllChats' | 'openChat' | 'openChatWithInfo' | 'openLinkedChat' |
|
'preloadTopChatMessages' | 'loadAllChats' | 'openChatWithInfo' | 'openLinkedChat' |
|
||||||
'openSupportChat' | 'openTipsChat' | 'focusMessageInComments' | 'openChatByPhoneNumber' |
|
'openSupportChat' | 'openTipsChat' | 'focusMessageInComments' | 'openChatByPhoneNumber' |
|
||||||
'loadFullChat' | 'loadTopChats' | 'requestChatUpdate' | 'updateChatMutedState' |
|
'loadFullChat' | 'loadTopChats' | 'requestChatUpdate' | 'updateChatMutedState' |
|
||||||
'joinChannel' | 'leaveChannel' | 'deleteChannel' | 'toggleChatPinned' | 'toggleChatArchived' | 'toggleChatUnread' |
|
'joinChannel' | 'leaveChannel' | 'deleteChannel' | 'toggleChatPinned' | 'toggleChatArchived' | 'toggleChatUnread' |
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user