mirror of
https://github.com/danog/telegram-tt.git
synced 2024-11-30 04:39:00 +01:00
[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) => {
|
||||
const { id, threadId } = payload!;
|
||||
const { id, threadId = MAIN_THREAD_ID } = payload;
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { currentUserId } = global;
|
||||
const chat = selectChat(global, id);
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { addActionHandler, setGlobal } from '../../index';
|
||||
|
||||
import { MAIN_THREAD_ID } from '../../../api/types';
|
||||
|
||||
import {
|
||||
exitMessageSelectMode, replaceThreadParam, updateCurrentMessageList,
|
||||
} from '../../reducers';
|
||||
@ -8,8 +10,11 @@ import { closeLocalTextSearch } from './localSearch';
|
||||
|
||||
addActionHandler('openChat', (global, actions, payload) => {
|
||||
const {
|
||||
id, threadId = -1, type = 'thread', shouldReplaceHistory = false,
|
||||
} = payload!;
|
||||
id,
|
||||
threadId = MAIN_THREAD_ID,
|
||||
type = 'thread',
|
||||
shouldReplaceHistory = false,
|
||||
} = payload;
|
||||
|
||||
const currentMessageList = selectCurrentMessageList(global);
|
||||
|
||||
@ -19,7 +24,10 @@ addActionHandler('openChat', (global, actions, payload) => {
|
||||
|| currentMessageList.threadId !== threadId
|
||||
|| currentMessageList.type !== type
|
||||
)) {
|
||||
global = replaceThreadParam(global, id, threadId, 'replyStack', []);
|
||||
if (id) {
|
||||
global = replaceThreadParam(global, id, threadId, 'replyStack', []);
|
||||
}
|
||||
|
||||
global = exitMessageSelectMode(global);
|
||||
global = closeLocalTextSearch(global);
|
||||
|
||||
|
@ -509,6 +509,12 @@ export type GlobalState = {
|
||||
|
||||
export interface ActionPayloads {
|
||||
apiUpdate: ApiUpdate;
|
||||
openChat: {
|
||||
id: string | undefined;
|
||||
threadId?: number;
|
||||
type?: MessageListType;
|
||||
shouldReplaceHistory?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export type NonTypedActionNames = (
|
||||
@ -525,7 +531,7 @@ export type NonTypedActionNames = (
|
||||
'setAuthPhoneNumber' | 'setAuthCode' | 'setAuthPassword' | 'signUp' | 'returnToAuthPhoneNumber' | 'signOut' |
|
||||
'setAuthRememberMe' | 'clearAuthError' | 'uploadProfilePhoto' | 'goToAuthQrCode' | 'clearCache' |
|
||||
// chats
|
||||
'preloadTopChatMessages' | 'loadAllChats' | 'openChat' | 'openChatWithInfo' | 'openLinkedChat' |
|
||||
'preloadTopChatMessages' | 'loadAllChats' | 'openChatWithInfo' | 'openLinkedChat' |
|
||||
'openSupportChat' | 'openTipsChat' | 'focusMessageInComments' | 'openChatByPhoneNumber' |
|
||||
'loadFullChat' | 'loadTopChats' | 'requestChatUpdate' | 'updateChatMutedState' |
|
||||
'joinChannel' | 'leaveChannel' | 'deleteChannel' | 'toggleChatPinned' | 'toggleChatArchived' | 'toggleChatUnread' |
|
||||
|
Loading…
Reference in New Issue
Block a user