[Refactoring] TeactN: addReducer => addActionHandler, getDispatch => getActions

This commit is contained in:
Alexander Zinchuk 2022-03-19 21:19:08 +01:00
parent 10749c62ca
commit b025fccf0f
212 changed files with 752 additions and 754 deletions

View File

@ -1,5 +1,5 @@
import React, { FC, useEffect } from './lib/teact/teact';
import { getDispatch, withGlobal } from './modules';
import { getActions, withGlobal } from './modules';
import { GlobalState } from './global/types';
@ -19,7 +19,7 @@ import { hasStoredSession } from './util/sessions';
type StateProps = Pick<GlobalState, 'authState'>;
const App: FC<StateProps> = ({ authState }) => {
const { disconnect } = getDispatch();
const { disconnect } = getActions();
const [isInactive, markInactive] = useFlag(false);

View File

@ -1,4 +1,4 @@
import { getDispatch, getGlobal } from '../modules';
import { getActions, getGlobal } from '../modules';
import { DEBUG } from '../config';
@ -10,5 +10,5 @@ if (DEBUG) {
}
if (!getGlobal().connectionState) {
getDispatch().initApi();
getActions().initApi();
}

View File

@ -1,5 +1,5 @@
import React, { FC, useEffect, memo } from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { GlobalState } from '../../global/types';
@ -25,7 +25,7 @@ const Auth: FC<StateProps> = ({
}) => {
const {
reset, initApi, returnToAuthPhoneNumber, goToAuthQrCode,
} = getDispatch();
} = getActions();
useEffect(() => {
reset();

View File

@ -2,7 +2,7 @@ import { FormEvent } from 'react';
import React, {
FC, useState, useEffect, useCallback, memo, useRef,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { GlobalState } from '../../global/types';
import { IS_TOUCH_ENV } from '../../util/environment';
@ -29,7 +29,7 @@ const AuthCode: FC<StateProps> = ({
setAuthCode,
returnToAuthPhoneNumber,
clearAuthError,
} = getDispatch();
} = getActions();
const lang = useLang();
// eslint-disable-next-line no-null/no-null

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useState,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { GlobalState } from '../../global/types';
@ -16,7 +16,7 @@ type StateProps = Pick<GlobalState, 'authIsLoading' | 'authError' | 'authHint'>;
const AuthPassword: FC<StateProps> = ({
authIsLoading, authError, authHint,
}) => {
const { setAuthPassword, clearAuthError } = getDispatch();
const { setAuthPassword, clearAuthError } = getActions();
const lang = useLang();
const [showPassword, setShowPassword] = useState(false);

View File

@ -5,7 +5,7 @@ import monkeyPath from '../../assets/monkey.svg';
import React, {
FC, memo, useCallback, useEffect, useLayoutEffect, useRef, useState,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { GlobalState } from '../../global/types';
import { LangCode } from '../../types';
@ -62,7 +62,7 @@ const AuthPhoneNumber: FC<StateProps> = ({
clearAuthError,
goToAuthQrCode,
setSettingOption,
} = getDispatch();
} = getActions();
const lang = useLang();
// eslint-disable-next-line no-null/no-null

View File

@ -2,7 +2,7 @@ import QrCreator from 'qr-creator';
import React, {
FC, useEffect, useRef, memo, useCallback,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { GlobalState } from '../../global/types';
import { LangCode } from '../../types';
@ -35,7 +35,7 @@ const AuthCode: FC<StateProps> = ({
const {
returnToAuthPhoneNumber,
setSettingOption,
} = getDispatch();
} = getActions();
const suggestedLanguage = getSuggestedLanguage();
const lang = useLang();

View File

@ -1,6 +1,6 @@
import { ChangeEvent } from 'react';
import React, { FC, useState, memo } from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { GlobalState } from '../../global/types';
@ -16,7 +16,7 @@ type StateProps = Pick<GlobalState, 'authIsLoading' | 'authError'>;
const AuthRegister: FC<StateProps> = ({
authIsLoading, authError,
}) => {
const { signUp, clearAuthError, uploadProfilePhoto } = getDispatch();
const { signUp, clearAuthError, uploadProfilePhoto } = getActions();
const lang = useLang();
const [isButtonShown, setIsButtonShown] = useState(false);

View File

@ -2,7 +2,7 @@ import { GroupCallParticipant } from '../../lib/secret-sauce';
import React, {
FC, memo, useEffect,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { ApiGroupCall } from '../../api/types';
@ -23,7 +23,7 @@ const ActiveCallHeader: FC<StateProps> = ({
meParticipant,
isGroupCallPanelHidden,
}) => {
const { toggleGroupCallPanel } = getDispatch();
const { toggleGroupCallPanel } = getActions();
const lang = useLang();

View File

@ -1,5 +1,5 @@
import React, { FC, memo, useState } from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import ConfirmDialog from '../ui/ConfirmDialog';
import Checkbox from '../ui/Checkbox';
@ -25,7 +25,7 @@ const CallFallbackConfirm: FC<OwnProps & StateProps> = ({
const {
closeCallFallbackConfirm,
inviteToCallFallback,
} = getDispatch();
} = getActions();
const [shouldRemove, setShouldRemove] = useState(true);
const renderingUserFullName = useCurrentOrPrev(userFullName, true);

View File

@ -5,7 +5,7 @@ import {
import React, {
FC, memo, useCallback, useEffect, useMemo, useRef, useState,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import '../../../modules/actions/calls';
import { IAnchorPosition } from '../../../types';
@ -75,7 +75,7 @@ const GroupCall: FC<OwnProps & StateProps> = ({
toggleGroupCallPanel,
connectToActiveGroupCall,
playGroupCallSound,
} = getDispatch();
} = getActions();
const lang = useLang();
// eslint-disable-next-line no-null/no-null

View File

@ -1,6 +1,6 @@
import { GroupCallParticipant as TypeGroupCallParticipant } from '../../../lib/secret-sauce';
import React, { FC, memo, useMemo } from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import useLang from '../../../hooks/useLang';
import { selectActiveGroupCall } from '../../../modules/selectors/calls';
@ -27,7 +27,7 @@ const GroupCallParticipantList: FC<OwnProps & StateProps> = ({
const {
createGroupCallInviteLink,
loadMoreGroupCallParticipants,
} = getDispatch();
} = getActions();
const lang = useLang();

View File

@ -2,7 +2,7 @@ import { GroupCallParticipant } from '../../../lib/secret-sauce';
import React, {
FC, memo, useCallback, useEffect, useState,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { IAnchorPosition } from '../../../types';
@ -56,7 +56,7 @@ const GroupCallParticipantMenu: FC<OwnProps & StateProps> = ({
toggleGroupCallPanel,
openChat,
requestToSpeak,
} = getDispatch();
} = getActions();
const lang = useLang();
const [isDeleteUserModalOpen, openDeleteUserModal, closeDeleteUserModal] = useFlag();

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useEffect, useMemo,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { ApiChat, ApiGroupCall, ApiUser } from '../../../api/types';
@ -38,7 +38,7 @@ const GroupCallTopPane: FC<OwnProps & StateProps> = ({
const {
joinGroupCall,
subscribeToGroupCallUpdates,
} = getDispatch();
} = getActions();
const lang = useLang();

View File

@ -2,7 +2,7 @@ import { GroupCallConnectionState } from '../../../lib/secret-sauce';
import React, {
FC, memo, useEffect, useMemo, useRef, useState,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import buildClassName from '../../../util/buildClassName';
import { vibrateShort } from '../../../util/vibrate';
@ -39,7 +39,7 @@ const MicrophoneButton: FC<StateProps> = ({
toggleGroupCallMute,
requestToSpeak,
playGroupCallSound,
} = getDispatch();
} = getActions();
const lang = useLang();
const muteMouseDownState = useRef('up');

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState,
} from '../../lib/teact/teact';
import { getDispatch } from '../../modules';
import { getActions } from '../../modules';
import {
ApiAudio, ApiMediaFormat, ApiMessage, ApiVoice,
@ -88,7 +88,7 @@ const Audio: FC<OwnProps> = ({
const seekerRef = useRef<HTMLDivElement>(null);
const lang = useLang();
const { isRtl } = lang;
const dispatch = getDispatch();
const dispatch = getActions();
const [isActivated, setIsActivated] = useState(false);
const shouldLoad = (isActivated || PRELOAD) && lastSyncTime;
@ -171,7 +171,7 @@ const Audio: FC<OwnProps> = ({
onPlay(message.id, message.chatId);
}
getDispatch().setAudioPlayerOrigin({ origin });
getActions().setAudioPlayerOrigin({ origin });
setIsActivated(!isActivated);
playPause();
}, [isUploading, isPlaying, isActivated, playPause, onCancelUpload, onPlay, message.id, message.chatId, origin]);

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useEffect,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { GlobalState } from '../../global/types';
import { ApiChat, ApiCountryCode, ApiUser } from '../../api/types';
@ -48,7 +48,7 @@ const ChatExtra: FC<OwnProps & StateProps> = ({
loadFullUser,
showNotification,
updateChatMutedState,
} = getDispatch();
} = getActions();
const {
id: userId,

View File

@ -1,5 +1,5 @@
import React, { FC, useCallback } from '../../lib/teact/teact';
import { getDispatch } from '../../modules';
import { getActions } from '../../modules';
import buildClassName from '../../util/buildClassName';
@ -14,7 +14,7 @@ type OwnProps = {
const ChatLink: FC<OwnProps> = ({
className, chatId, children,
}) => {
const { openChat } = getDispatch();
const { openChat } = getActions();
const handleClick = useCallback(() => {
if (chatId) {

View File

@ -1,5 +1,5 @@
import React, { FC, useCallback, memo } from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { ApiChat } from '../../api/types';
@ -63,7 +63,7 @@ const DeleteChatModal: FC<OwnProps & StateProps> = ({
deleteChannel,
deleteChatUser,
blockContact,
} = getDispatch();
} = getActions();
const lang = useLang();
const chatTitle = getChatTitle(lang, chat);

View File

@ -1,5 +1,5 @@
import React, { FC, useCallback, memo } from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { ApiMessage } from '../../api/types';
import { IAlbum } from '../../types';
@ -52,7 +52,7 @@ const DeleteMessageModal: FC<OwnProps & StateProps> = ({
const {
deleteMessages,
deleteScheduledMessages,
} = getDispatch();
} = getActions();
const handleDeleteMessageForAll = useCallback(() => {
const messageIds = album?.messages

View File

@ -1,7 +1,7 @@
import React, {
FC, useCallback, memo, useRef, useEffect, useState,
} from '../../lib/teact/teact';
import { getDispatch } from '../../modules';
import { getActions } from '../../modules';
import { ApiMessage } from '../../api/types';
@ -58,7 +58,7 @@ const Document: FC<OwnProps> = ({
onDateClick,
isDownloading,
}) => {
const dispatch = getDispatch();
const dispatch = getActions();
// eslint-disable-next-line no-null/no-null
const ref = useRef<HTMLDivElement>(null);

View File

@ -5,7 +5,7 @@ import { ApiGroupCall } from '../../api/types';
import buildClassName from '../../util/buildClassName';
import Link from '../ui/Link';
import { getDispatch } from '../../modules';
import { getActions } from '../../modules';
type OwnProps = {
className?: string;
@ -16,7 +16,7 @@ type OwnProps = {
const GroupCallLink: FC<OwnProps> = ({
className, groupCall, children,
}) => {
const { joinGroupCall } = getDispatch();
const { joinGroupCall } = getActions();
const handleClick = useCallback(() => {
if (groupCall) {

View File

@ -2,7 +2,7 @@ import { MouseEvent as ReactMouseEvent } from 'react';
import React, {
FC, useEffect, useCallback, memo,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { ApiChat, ApiTypingStatus } from '../../api/types';
import { GlobalState } from '../../global/types';
@ -63,7 +63,7 @@ const GroupChatInfo: FC<OwnProps & StateProps> = ({
const {
loadFullChat,
openMediaViewer,
} = getDispatch();
} = getActions();
const isSuperGroup = chat && isChatSuperGroup(chat);
const { id: chatId, isMin, isRestricted } = chat || {};

View File

@ -1,5 +1,5 @@
import React, { FC, useCallback } from '../../lib/teact/teact';
import { getDispatch } from '../../modules';
import { getActions } from '../../modules';
import { ApiMessage } from '../../api/types';
@ -16,7 +16,7 @@ type OwnProps = {
const MessageLink: FC<OwnProps> = ({
className, message, children,
}) => {
const { focusMessage } = getDispatch();
const { focusMessage } = getActions();
const handleMessageClick = useCallback((): void => {
if (message) {

View File

@ -1,5 +1,5 @@
import React, { FC, useCallback, memo } from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { selectChat, selectIsChatWithSelf, selectUser } from '../../modules/selectors';
import {
@ -44,7 +44,7 @@ const PinMessageModal: FC<OwnProps & StateProps> = ({
contactName,
onClose,
}) => {
const { pinMessage } = getDispatch();
const { pinMessage } = getActions();
const handlePinMessageForAll = useCallback(() => {
pinMessage({

View File

@ -2,7 +2,7 @@ import { MouseEvent as ReactMouseEvent } from 'react';
import React, {
FC, useEffect, useCallback, memo,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { ApiUser, ApiTypingStatus, ApiUserStatus } from '../../api/types';
import { GlobalState } from '../../global/types';
@ -64,7 +64,7 @@ const PrivateChatInfo: FC<OwnProps & StateProps> = ({
const {
loadFullUser,
openMediaViewer,
} = getDispatch();
} = getActions();
const { id: userId } = user || {};
const fullName = getUserFullName(user);

View File

@ -1,7 +1,7 @@
import React, {
FC, useEffect, useCallback, memo, useState,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { ApiUser, ApiChat, ApiUserStatus } from '../../api/types';
import { GlobalState } from '../../global/types';
@ -53,7 +53,7 @@ const ProfileInfo: FC<OwnProps & StateProps> = ({
const {
loadFullUser,
openMediaViewer,
} = getDispatch();
} = getActions();
const lang = useLang();

View File

@ -3,7 +3,7 @@ import { ChangeEvent } from 'react';
import React, {
FC, memo, useCallback, useState,
} from '../../lib/teact/teact';
import { getDispatch } from '../../modules';
import { getActions } from '../../modules';
import { ApiReportReason } from '../../api/types';
@ -28,7 +28,7 @@ const ReportMessageModal: FC<OwnProps> = ({
const {
reportMessages,
exitMessageSelectMode,
} = getDispatch();
} = getActions();
const [selectedReason, setSelectedReason] = useState<ApiReportReason>('spam');
const [description, setDescription] = useState('');

View File

@ -1,5 +1,5 @@
import React, { FC, memo, useCallback } from '../../lib/teact/teact';
import { getDispatch } from '../../modules';
import { getActions } from '../../modules';
import convertPunycode from '../../lib/punycode';
import {
@ -23,7 +23,7 @@ const SafeLink: FC<OwnProps> = ({
children,
isRtl,
}) => {
const { toggleSafeLinkModal, openTelegramLink } = getDispatch();
const { toggleSafeLinkModal, openTelegramLink } = getActions();
const content = children || text;
const isNotSafe = url !== content;

View File

@ -1,5 +1,5 @@
import React, { FC, useCallback, memo } from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import useLang from '../../hooks/useLang';
import { selectChatMessage } from '../../modules/selectors';
@ -27,7 +27,7 @@ const SeenByModal: FC<OwnProps & StateProps> = ({
const {
openChat,
closeSeenByModal,
} = getDispatch();
} = getActions();
const lang = useLang();

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useEffect, useRef,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { ApiSticker, ApiStickerSet } from '../../api/types';
@ -47,7 +47,7 @@ const StickerSetModal: FC<OwnProps & StateProps> = ({
loadStickers,
toggleStickerSet,
sendMessage,
} = getDispatch();
} = getActions();
// eslint-disable-next-line no-null/no-null
const containerRef = useRef<HTMLDivElement>(null);

View File

@ -1,5 +1,5 @@
import React, { FC, useEffect } from '../../lib/teact/teact';
import { getDispatch, getGlobal, withGlobal } from '../../modules';
import { getActions, getGlobal, withGlobal } from '../../modules';
import { ApiMediaFormat } from '../../api/types';
import { GlobalState } from '../../global/types';
@ -85,7 +85,7 @@ const UiLoader: FC<OwnProps & StateProps> = ({
shouldSkipHistoryAnimations,
leftColumnWidth,
}) => {
const { setIsUiReady } = getDispatch();
const { setIsUiReady } = getActions();
const [isReady, markReady] = useFlag();
const {

View File

@ -5,7 +5,7 @@ import { ApiChat, ApiUser } from '../../api/types';
import buildClassName from '../../util/buildClassName';
import Link from '../ui/Link';
import { getDispatch } from '../../modules';
import { getActions } from '../../modules';
type OwnProps = {
className?: string;
@ -16,7 +16,7 @@ type OwnProps = {
const UserLink: FC<OwnProps> = ({
className, sender, children,
}) => {
const { openChat } = getDispatch();
const { openChat } = getActions();
const handleClick = useCallback(() => {
if (sender) {

View File

@ -1,6 +1,6 @@
import { MouseEvent } from 'react';
import React from '../../../lib/teact/teact';
import { getDispatch } from '../../../modules';
import { getActions } from '../../../modules';
import { ApiFormattedText, ApiMessageEntity, ApiMessageEntityTypes } from '../../../api/types';
import renderText, { TextFilter } from './renderText';
@ -454,10 +454,10 @@ function getLinkUrl(entityContent: string, entity: ApiMessageEntity) {
}
function handleBotCommandClick(e: MouseEvent<HTMLAnchorElement>) {
getDispatch().sendBotCommand({ command: e.currentTarget.innerText });
getActions().sendBotCommand({ command: e.currentTarget.innerText });
}
function handleHashtagClick(e: MouseEvent<HTMLAnchorElement>) {
getDispatch().setLocalTextSearchQuery({ query: e.currentTarget.innerText });
getDispatch().searchTextMessagesLocal();
getActions().setLocalTextSearchQuery({ query: e.currentTarget.innerText });
getActions().searchTextMessagesLocal();
}

View File

@ -2,7 +2,7 @@ import {
useCallback, useEffect, useRef, useState,
} from '../../../lib/teact/teact';
import safePlay from '../../../util/safePlay';
import { getDispatch } from '../../../modules';
import { getActions } from '../../../modules';
import useMedia from '../../../hooks/useMedia';
import { ActiveEmojiInteraction } from '../../../global/types';
import useFlag from '../../../hooks/useFlag';
@ -29,7 +29,7 @@ export default function useAnimatedEmoji(
) {
const {
interactWithAnimatedEmoji, sendEmojiInteraction, sendWatchingEmojiInteraction,
} = getDispatch();
} = getActions();
const hasEffect = localEffect || emoji;
const [isAnimationLoaded, markAnimationLoaded] = useFlag();

View File

@ -1,7 +1,7 @@
import React, {
FC, useCallback, memo, useMemo, useState,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { ApiChatFolder } from '../../api/types';
@ -31,7 +31,7 @@ const ChatFolderModal: FC<OwnProps & StateProps> = ({
onClose,
onCloseAnimationEnd,
}) => {
const { editChatFolders } = getDispatch();
const { editChatFolders } = getActions();
const lang = useLang();

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useEffect, useRef, useState,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { LeftColumnContent, SettingsScreens } from '../../types';
@ -57,7 +57,7 @@ const LeftColumn: FC<StateProps> = ({
clearTwoFaError,
setLeftColumnWidth,
resetLeftColumnWidth,
} = getDispatch();
} = getActions();
// eslint-disable-next-line no-null/no-null
const resizeRef = useRef<HTMLDivElement>(null);

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useLayoutEffect, useMemo, useRef,
} from '../../../lib/teact/teact';
import { getDispatch, getGlobal, withGlobal } from '../../../modules';
import { getActions, getGlobal, withGlobal } from '../../../modules';
import useLang, { LangFn } from '../../../hooks/useLang';
@ -108,7 +108,7 @@ const Chat: FC<OwnProps & StateProps> = ({
const {
openChat,
focusLastMessage,
} = getDispatch();
} = getActions();
// eslint-disable-next-line no-null/no-null
const ref = useRef<HTMLDivElement>(null);

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useEffect, useMemo, useRef,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { ApiChatFolder } from '../../../api/types';
import { SettingsScreens } from '../../../types';
@ -51,7 +51,7 @@ const ChatFolders: FC<OwnProps & StateProps> = ({
loadChatFolders,
setActiveChatFolder,
openChat,
} = getDispatch();
} = getActions();
// eslint-disable-next-line no-null/no-null
const transitionRef = useRef<HTMLDivElement>(null);

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useMemo, useEffect,
} from '../../../lib/teact/teact';
import { getDispatch } from '../../../modules';
import { getActions } from '../../../modules';
import { SettingsScreens } from '../../../types';
import { FolderEditDispatch } from '../../../hooks/reducers/useFoldersReducer';
@ -41,7 +41,7 @@ const ChatList: FC<OwnProps> = ({
foldersDispatch,
onScreenSelect,
}) => {
const { openChat, openNextChat } = getDispatch();
const { openChat, openNextChat } = getActions();
const resolvedFolderId = (
folderType === 'all' ? ALL_FOLDER_ID : folderType === 'archived' ? ARCHIVED_FOLDER_ID : folderId!

View File

@ -1,7 +1,7 @@
import React, {
FC, useEffect, useCallback, useMemo, memo,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { ApiUser, ApiUserStatus } from '../../../api/types';
@ -43,7 +43,7 @@ const ContactList: FC<OwnProps & StateProps> = ({
const {
loadContactList,
openChat,
} = getDispatch();
} = getActions();
// Due to the parent Transition, this component never gets unmounted,
// that's why we use throttled API call on every update.

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useMemo,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { ISettings, LeftColumnContent } from '../../../types';
import { ApiChat } from '../../../api/types';
@ -95,7 +95,7 @@ const LeftMainHeader: FC<OwnProps & StateProps> = ({
setGlobalSearchDate,
setSettingOption,
setGlobalSearchChatId,
} = getDispatch();
} = getActions();
const lang = useLang();
const hasMenu = content === LeftColumnContent.ChatList;

View File

@ -1,7 +1,7 @@
import React, {
FC, useCallback, useEffect, useMemo, memo,
} from '../../../lib/teact/teact';
import { getDispatch, getGlobal, withGlobal } from '../../../modules';
import { getActions, getGlobal, withGlobal } from '../../../modules';
import { ApiChat } from '../../../api/types';
@ -52,7 +52,7 @@ const NewChatStep1: FC<OwnProps & StateProps> = ({
const {
loadContactList,
setGlobalSearchQuery,
} = getDispatch();
} = getActions();
// Due to the parent Transition, this component never gets unmounted,
// that's why we use throttled API call on every update.

View File

@ -1,7 +1,7 @@
import React, {
FC, useState, useCallback, useEffect, memo,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { ChatCreationProgress } from '../../../types';
@ -42,7 +42,7 @@ const NewChatStep2: FC<OwnProps & StateProps > = ({
const {
createGroupChat,
createChannel,
} = getDispatch();
} = getActions();
const lang = useLang();

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useMemo,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { AudioOrigin, LoadMoreDirection } from '../../../types';
@ -43,7 +43,7 @@ const AudioResults: FC<OwnProps & StateProps> = ({
searchMessagesGlobal,
focusMessage,
openAudioPlayer,
} = getDispatch();
} = getActions();
const lang = useLang();
const currentType = isVoice ? 'voice' : 'audio';

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import {
ApiChat, ApiUser, ApiMessage, ApiMessageOutgoingStatus,
@ -52,7 +52,7 @@ const ChatMessage: FC<OwnProps & StateProps> = ({
privateChatUser,
lastSyncTime,
}) => {
const { focusMessage } = getDispatch();
const { focusMessage } = getActions();
const mediaThumbnail = getMessageMediaThumbDataUri(message);
const mediaBlobUrl = useMedia(getMessageMediaHash(message, 'micro'));

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useMemo,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { ApiChat, ApiMessage } from '../../../api/types';
import { LoadMoreDirection } from '../../../types';
@ -45,7 +45,7 @@ const ChatMessageResults: FC<OwnProps & StateProps> = ({
lastSyncTime,
onSearchDateSelect,
}) => {
const { searchMessagesGlobal } = getDispatch();
const { searchMessagesGlobal } = getActions();
const lang = useLang();
const handleLoadMore = useCallback(({ direction }: { direction: LoadMoreDirection }) => {

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useMemo, useState,
} from '../../../lib/teact/teact';
import { getDispatch, getGlobal, withGlobal } from '../../../modules';
import { getActions, getGlobal, withGlobal } from '../../../modules';
import { ApiChat, ApiMessage } from '../../../api/types';
import { LoadMoreDirection } from '../../../types';
@ -61,7 +61,7 @@ const ChatResults: FC<OwnProps & StateProps> = ({
}) => {
const {
openChat, addRecentlyFoundChatId, searchMessagesGlobal, setGlobalSearchChatId,
} = getDispatch();
} = getActions();
const lang = useLang();

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useMemo, useRef,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { ApiMessage } from '../../../api/types';
import { LoadMoreDirection } from '../../../types';
@ -45,7 +45,7 @@ const FileResults: FC<OwnProps & StateProps> = ({
const {
searchMessagesGlobal,
focusMessage,
} = getDispatch();
} = getActions();
// eslint-disable-next-line no-null/no-null
const containerRef = useRef<HTMLDivElement>(null);

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useState, useMemo, useRef,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { GlobalSearchContent } from '../../../types';
@ -60,7 +60,7 @@ const LeftSearch: FC<OwnProps & StateProps> = ({
const {
setGlobalSearchContent,
setGlobalSearchDate,
} = getDispatch();
} = getActions();
const lang = useLang();
const [activeTab, setActiveTab] = useState(currentContent);

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useMemo, useRef,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { LoadMoreDirection } from '../../../types';
@ -43,7 +43,7 @@ const LinkResults: FC<OwnProps & StateProps> = ({
const {
searchMessagesGlobal,
focusMessage,
} = getDispatch();
} = getActions();
// eslint-disable-next-line no-null/no-null
const containerRef = useRef<HTMLDivElement>(null);

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useMemo, useRef,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { LoadMoreDirection, MediaViewerOrigin } from '../../../types';
@ -41,7 +41,7 @@ const MediaResults: FC<OwnProps & StateProps> = ({
const {
searchMessagesGlobal,
openMediaViewer,
} = getDispatch();
} = getActions();
// eslint-disable-next-line no-null/no-null
const containerRef = useRef<HTMLDivElement>(null);

View File

@ -1,7 +1,7 @@
import React, {
FC, useEffect, useCallback, useRef, memo,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { ApiUser } from '../../../api/types';
@ -39,7 +39,7 @@ const RecentContacts: FC<OwnProps & StateProps> = ({
const {
loadTopUsers, loadContactList, openChat,
addRecentlyFoundChatId, clearRecentlyFoundChats,
} = getDispatch();
} = getActions();
// eslint-disable-next-line no-null/no-null
const topUsersRef = useRef<HTMLDivElement>(null);

View File

@ -1,7 +1,7 @@
import React, {
FC, useMemo, useState, memo, useRef, useCallback, useEffect,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { ApiUser } from '../../../api/types';
@ -37,7 +37,7 @@ const BlockUserModal: FC<OwnProps & StateProps> = ({
loadContactList,
setUserSearchQuery,
blockContact,
} = getDispatch();
} = getActions();
const lang = useLang();
const [filter, setFilter] = useState('');

View File

@ -1,5 +1,5 @@
import React, { FC, memo, useCallback } from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { SettingsScreens, ISettings } from '../../../types';
@ -55,7 +55,7 @@ const SettingsDataStorage: FC<OwnProps & StateProps> = ({
canAutoPlayVideos,
autoLoadFileMaxSizeMb,
}) => {
const { setSettingOption } = getDispatch();
const { setSettingOption } = getActions();
const lang = useLang();

View File

@ -2,7 +2,7 @@ import { ChangeEvent } from 'react';
import React, {
FC, useState, useCallback, memo, useEffect, useMemo,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { ApiMediaFormat } from '../../../api/types';
import { ProfileEditProgress, SettingsScreens } from '../../../types';
@ -60,7 +60,7 @@ const SettingsEditProfile: FC<OwnProps & StateProps> = ({
loadCurrentUser,
updateProfile,
checkUsername,
} = getDispatch();
} = getActions();
const lang = useLang();

View File

@ -1,7 +1,7 @@
import React, {
FC, useCallback, memo, useRef, useState,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { SettingsScreens, ISettings, TimeFormat } from '../../../types';
import { ApiSticker, ApiStickerSet } from '../../../api/types';
@ -72,7 +72,7 @@ const SettingsGeneral: FC<OwnProps & StateProps> = ({
}) => {
const {
setSettingOption,
} = getDispatch();
} = getActions();
// eslint-disable-next-line no-null/no-null
const stickerSettingsRef = useRef<HTMLDivElement>(null);

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useEffect, useCallback, useRef,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { SettingsScreens, ThemeKey, UPLOADING_WALLPAPER_SLUG } from '../../../types';
import { ApiWallpaper } from '../../../api/types';
@ -51,7 +51,7 @@ const SettingsGeneralBackground: FC<OwnProps & StateProps> = ({
loadWallpapers,
uploadWallpaper,
setThemeSettings,
} = getDispatch();
} = getActions();
const themeRef = useRef<string>();
themeRef.current = theme;

View File

@ -2,7 +2,7 @@ import { ChangeEvent, MutableRefObject, RefObject } from 'react';
import React, {
FC, memo, useCallback, useEffect, useRef, useState,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { SettingsScreens, ThemeKey } from '../../../types';
@ -57,7 +57,7 @@ const SettingsGeneralBackground: FC<OwnProps & StateProps> = ({
theme,
backgroundColor,
}) => {
const { setThemeSettings } = getDispatch();
const { setThemeSettings } = getActions();
const themeRef = useRef<string>();
themeRef.current = theme;

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useMemo, useState,
} from '../../../lib/teact/teact';
import { getDispatch } from '../../../modules';
import { getActions } from '../../../modules';
import { SettingsScreens } from '../../../types';
@ -31,7 +31,7 @@ const SettingsHeader: FC<OwnProps> = ({
const {
signOut,
deleteChatFolder,
} = getDispatch();
} = getActions();
const [isSignOutDialogOpen, setIsSignOutDialogOpen] = useState(false);
const [isDeleteFolderDialogOpen, setIsDeleteFolderDialogOpen] = useState(false);

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useEffect, useMemo, useState,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { ISettings, LangCode, SettingsScreens } from '../../../types';
import { ApiLanguage } from '../../../api/types';
@ -31,7 +31,7 @@ const SettingsLanguage: FC<OwnProps & StateProps> = ({
const {
loadLanguages,
setSettingOption,
} = getDispatch();
} = getActions();
const [selectedLanguage, setSelectedLanguage] = useState<string>(language);
const [isLoading, markIsLoading, unmarkIsLoading] = useFlag();

View File

@ -1,5 +1,5 @@
import React, { FC, memo, useEffect } from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { SettingsScreens } from '../../../types';
import { ApiUser } from '../../../api/types';
@ -30,7 +30,7 @@ const SettingsMain: FC<OwnProps & StateProps> = ({
currentUser,
lastSyncTime,
}) => {
const { loadProfilePhotos } = getDispatch();
const { loadProfilePhotos } = getActions();
const lang = useLang();
const profileId = currentUser?.id;

View File

@ -3,7 +3,7 @@ import useDebounce from '../../../hooks/useDebounce';
import React, {
FC, memo, useCallback, useEffect,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { SettingsScreens } from '../../../types';
@ -53,7 +53,7 @@ const SettingsNotifications: FC<OwnProps & StateProps> = ({
updateContactSignUpNotification,
updateNotificationSettings,
updateWebNotificationSettings,
} = getDispatch();
} = getActions();
useEffect(() => {
loadNotificationSettings();

View File

@ -1,5 +1,5 @@
import React, { FC, memo, useEffect } from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { PrivacyVisibility, SettingsScreens } from '../../../types';
@ -50,7 +50,7 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
loadAuthorizations,
loadContentSettings,
updateContentSettings,
} = getDispatch();
} = getActions();
useEffect(() => {
loadBlockedContacts();

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useEffect, useMemo,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { ApiSession } from '../../../api/types';
import { SettingsScreens } from '../../../types';
@ -34,7 +34,7 @@ const SettingsPrivacyActiveSessions: FC<OwnProps & StateProps> = ({
loadAuthorizations,
terminateAuthorization,
terminateAllAuthorizations,
} = getDispatch();
} = getActions();
const [isConfirmTerminateAllDialogOpen, openConfirmTerminateAllDialog, closeConfirmTerminateAllDialog] = useFlag();
useEffect(() => {

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { ApiChat, ApiCountryCode, ApiUser } from '../../../api/types';
import { SettingsScreens } from '../../../types';
@ -45,7 +45,7 @@ const SettingsPrivacyBlockedUsers: FC<OwnProps & StateProps> = ({
blockedIds,
phoneCodeList,
}) => {
const { unblockContact } = getDispatch();
const { unblockContact } = getActions();
const lang = useLang();
const [isBlockUserModalOpen, openBlockUserModal, closeBlockUserModal] = useFlag();

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useMemo,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { ApiChat, ApiUser } from '../../../api/types';
import { ApiPrivacySettings, SettingsScreens } from '../../../types';
@ -38,7 +38,7 @@ const SettingsPrivacyVisibility: FC<OwnProps & StateProps> = ({
blockChatIds,
chatsById,
}) => {
const { setPrivacyVisibility } = getDispatch();
const { setPrivacyVisibility } = getActions();
const lang = useLang();

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useMemo, useState,
} from '../../../lib/teact/teact';
import { getDispatch, getGlobal, withGlobal } from '../../../modules';
import { getActions, getGlobal, withGlobal } from '../../../modules';
import { GlobalState } from '../../../global/types';
import { ApiPrivacySettings, SettingsScreens } from '../../../types';
@ -39,7 +39,7 @@ const SettingsPrivacyVisibilityExceptionList: FC<OwnProps & StateProps> = ({
currentUserId,
settings,
}) => {
const { setPrivacySettings } = getDispatch();
const { setPrivacySettings } = getActions();
const lang = useLang();

View File

@ -1,5 +1,5 @@
import React, { FC, memo, useCallback } from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { SettingsScreens } from '../../../types';
import { ApiAvailableReaction } from '../../../api/types';
@ -27,7 +27,7 @@ const SettingsQuickReaction: FC<OwnProps & StateProps> = ({
availableReactions,
selectedReaction,
}) => {
const { setDefaultReaction } = getDispatch();
const { setDefaultReaction } = getActions();
useHistoryBack(isActive, onReset, onScreenSelect, SettingsScreens.General);
const options = availableReactions?.filter((l) => !l.isInactive).map((l) => {

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useEffect, useMemo, useState,
} from '../../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../../modules';
import { getActions, withGlobal } from '../../../../modules';
import { SettingsScreens } from '../../../../types';
@ -66,7 +66,7 @@ const SettingsFoldersEdit: FC<OwnProps & StateProps> = ({
const {
editChatFolder,
addChatFolder,
} = getDispatch();
} = getActions();
const [animationData, setAnimationData] = useState<string>();
const [isAnimationLoaded, setIsAnimationLoaded] = useState(false);

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useMemo, useCallback, useState, useEffect,
} from '../../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../../modules';
import { getActions, withGlobal } from '../../../../modules';
import { ApiChatFolder } from '../../../../api/types';
import { SettingsScreens } from '../../../../types';
@ -51,7 +51,7 @@ const SettingsFoldersMain: FC<OwnProps & StateProps> = ({
loadRecommendedChatFolders,
addChatFolder,
showDialog,
} = getDispatch();
} = getActions();
const [animationData, setAnimationData] = useState<string>();
const [isAnimationLoaded, setIsAnimationLoaded] = useState(false);

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useEffect,
} from '../../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../../modules';
import { getActions, withGlobal } from '../../../../modules';
import { GlobalState } from '../../../../global/types';
import { SettingsScreens } from '../../../../types';
@ -48,7 +48,7 @@ const SettingsTwoFa: FC<OwnProps & StateProps> = ({
updateRecoveryEmail,
provideTwoFaEmailCode,
clearPassword,
} = getDispatch();
} = getActions();
useEffect(() => {
if (waitingEmailCodeLength) {

View File

@ -1,5 +1,5 @@
import React, { FC, memo, useEffect } from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import {
ApiContact, ApiError, ApiInviteInfo, ApiPhoto,
@ -27,7 +27,7 @@ const Dialogs: FC<StateProps> = ({ dialogs }) => {
acceptInviteConfirmation,
sendMessage,
showNotification,
} = getDispatch();
} = getActions();
const [isModalOpen, openModal, closeModal] = useFlag();
const lang = useLang();

View File

@ -1,5 +1,5 @@
import { FC, memo, useEffect } from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { Thread } from '../../global/types';
import { ApiMediaFormat, ApiMessage } from '../../api/types';
@ -24,7 +24,7 @@ const DownloadManager: FC<StateProps> = ({
activeDownloads,
messages,
}) => {
const { cancelMessageMediaDownload } = getDispatch();
const { cancelMessageMediaDownload } = getActions();
useEffect(() => {
Object.entries(activeDownloads).forEach(([chatId, messageIds]) => {

View File

@ -1,7 +1,7 @@
import React, {
FC, useMemo, useState, memo, useRef, useCallback, useEffect,
} from '../../lib/teact/teact';
import { getDispatch, getGlobal, withGlobal } from '../../modules';
import { getActions, getGlobal, withGlobal } from '../../modules';
import { ApiChat, MAIN_THREAD_ID } from '../../api/types';
@ -43,7 +43,7 @@ const ForwardPicker: FC<OwnProps & StateProps> = ({
const {
setForwardChatId,
exitForwardMode,
} = getDispatch();
} = getActions();
const lang = useLang();
const [filter, setFilter] = useState('');

View File

@ -1,5 +1,5 @@
import React, { FC, memo, useCallback } from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import useLang from '../../hooks/useLang';
@ -16,7 +16,7 @@ type StateProps = {
const HistoryCalendar: FC<OwnProps & StateProps> = ({
isOpen, selectedAt,
}) => {
const { searchMessagesByDate, closeHistoryCalendar } = getDispatch();
const { searchMessagesByDate, closeHistoryCalendar } = getActions();
const handleJumpToDate = useCallback((date: Date) => {
searchMessagesByDate({ timestamp: date.valueOf() / 1000 });

View File

@ -1,7 +1,7 @@
import React, {
FC, useEffect, memo, useCallback,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { LangCode } from '../../types';
import { ApiMessage, ApiUpdateAuthorizationStateType, ApiUpdateConnectionStateType } from '../../api/types';
@ -122,7 +122,7 @@ const Main: FC<StateProps> = ({
openStickerSetShortName,
checkVersionNotification,
loadAppConfig,
} = getDispatch();
} = getActions();
if (DEBUG && !DEBUG_isLogged) {
DEBUG_isLogged = true;

View File

@ -1,5 +1,5 @@
import React, { FC, memo } from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { ApiNotification } from '../../api/types';
@ -13,7 +13,7 @@ type StateProps = {
};
const Notifications: FC<StateProps> = ({ notifications }) => {
const { dismissNotification } = getDispatch();
const { dismissNotification } = getActions();
if (!notifications.length) {
return undefined;

View File

@ -1,5 +1,5 @@
import React, { FC, memo, useCallback } from '../../lib/teact/teact';
import { getDispatch } from '../../modules';
import { getActions } from '../../modules';
import { ensureProtocol } from '../../util/ensureProtocol';
import renderText from '../common/helpers/renderText';
@ -13,7 +13,7 @@ export type OwnProps = {
};
const SafeLinkModal: FC<OwnProps> = ({ url }) => {
const { toggleSafeLinkModal } = getDispatch();
const { toggleSafeLinkModal } = getActions();
const lang = useLang();

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useEffect, useMemo, useRef, useState,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import {
ApiChat, ApiDimensions, ApiMediaFormat, ApiMessage, ApiUser,
@ -101,7 +101,7 @@ const MediaViewer: FC<StateProps> = ({
openForwardMenu,
focusMessage,
toggleChatInfo,
} = getDispatch();
} = getActions();
const isOpen = Boolean(avatarOwner || messageId);

View File

@ -4,7 +4,7 @@ import React, {
useCallback,
useMemo,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { ApiMessage } from '../../api/types';
@ -54,7 +54,7 @@ const MediaViewerActions: FC<OwnProps & StateProps> = ({
const {
downloadMessageMedia,
cancelMessageMediaDownload,
} = getDispatch();
} = getActions();
const { loadProgress: downloadProgress } = useMediaWithLoadProgress(
message && getMessageMediaHash(message, 'download'),

View File

@ -1,5 +1,5 @@
import React, { FC, useCallback } from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { ApiChat, ApiMessage, ApiUser } from '../../api/types';
@ -43,7 +43,7 @@ const SenderInfo: FC<OwnProps & StateProps> = ({
closeMediaViewer,
focusMessage,
toggleChatInfo,
} = getDispatch();
} = getActions();
const handleFocusMessage = useCallback(() => {
closeMediaViewer();

View File

@ -1,7 +1,7 @@
import React, {
FC, useCallback, useEffect, useMemo,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { AudioOrigin } from '../../types';
import {
@ -63,7 +63,7 @@ const AudioPlayer: FC<OwnProps & StateProps> = ({
setAudioPlayerMuted,
focusMessage,
closeAudioPlayer,
} = getDispatch();
} = getActions();
const lang = useLang();
const { audio, voice, video } = getMessageContent(message);

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useEffect, useRef,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { ApiSticker, ApiUpdateConnectionStateType } from '../../api/types';
@ -35,7 +35,7 @@ const ContactGreeting: FC<OwnProps & StateProps> = ({
loadGreetingStickers,
sendMessage,
markMessageListRead,
} = getDispatch();
} = getActions();
const lang = useLang();
// eslint-disable-next-line no-null/no-null

View File

@ -1,7 +1,7 @@
import React, {
FC, useCallback, memo, useEffect,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { selectCanDeleteSelectedMessages, selectCurrentChat, selectUser } from '../../modules/selectors';
import {
@ -46,7 +46,7 @@ const DeleteSelectedMessageModal: FC<OwnProps & StateProps> = ({
deleteMessages,
deleteScheduledMessages,
exitMessageSelectMode,
} = getDispatch();
} = getActions();
const prevIsOpen = usePrevious(isOpen);

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useEffect, useLayoutEffect, useRef, useState,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { ActiveEmojiInteraction } from '../../global/types';
import { ApiMediaFormat } from '../../api/types';
@ -38,7 +38,7 @@ const EmojiInteractionAnimation: FC<OwnProps & StateProps> = ({
localEffectAnimation,
activeEmojiInteraction,
}) => {
const { stopActiveEmojiInteraction } = getDispatch();
const { stopActiveEmojiInteraction } = getActions();
const [isHiding, startHiding] = useFlag(false);
const [isPlaying, startPlaying] = useFlag(false);

View File

@ -6,7 +6,7 @@ import React, {
useState,
useEffect,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { MessageListType } from '../../global/types';
import { MAIN_THREAD_ID } from '../../api/types';
@ -86,7 +86,7 @@ const HeaderActions: FC<OwnProps & StateProps> = ({
restartBot,
openCallFallbackConfirm,
requestNextManagementScreen,
} = getDispatch();
} = getActions();
// eslint-disable-next-line no-null/no-null
const menuButtonRef = useRef<HTMLButtonElement>(null);

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useEffect, useState,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { ApiChat } from '../../api/types';
import { IAnchorPosition } from '../../types';
@ -94,7 +94,7 @@ const HeaderMenuContainer: FC<OwnProps & StateProps> = ({
addContact,
openCallFallbackConfirm,
toggleStatistics,
} = getDispatch();
} = getActions();
const [isMenuOpen, setIsMenuOpen] = useState(true);
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useEffect, useMemo, useRef, useState,
} from '../../lib/teact/teact';
import { getDispatch, getGlobal, withGlobal } from '../../modules';
import { getActions, getGlobal, withGlobal } from '../../modules';
import {
ApiMessage, ApiRestrictionReason, MAIN_THREAD_ID,
@ -140,7 +140,7 @@ const MessageList: FC<OwnProps & StateProps> = ({
}) => {
const {
loadViewportMessages, setScrollOffset, loadSponsoredMessages, loadMessageReactions, copyMessagesByIds,
} = getDispatch();
} = getActions();
// eslint-disable-next-line no-null/no-null
const containerRef = useRef<HTMLDivElement>(null);

View File

@ -19,7 +19,7 @@ import useMessageObservers from './hooks/useMessageObservers';
import Message from './message/Message';
import SponsoredMessage from './message/SponsoredMessage';
import ActionMessage from './ActionMessage';
import { getDispatch } from '../../modules';
import { getActions } from '../../modules';
interface OwnProps {
chatId: string;
@ -74,7 +74,7 @@ const MessageListContent: FC<OwnProps> = ({
onFabToggle,
onNotchToggle,
}) => {
const { openHistoryCalendar } = getDispatch();
const { openHistoryCalendar } = getActions();
const {
observeIntersectionForMedia,

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useEffect,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { MessageListType } from '../../global/types';
@ -60,7 +60,7 @@ const MessageSelectToolbar: FC<OwnProps & StateProps> = ({
openForwardMenuForSelectedMessages,
downloadSelectedMessages,
copySelectedMessages,
} = getDispatch();
} = getActions();
const [isDeleteModalOpen, openDeleteModal, closeDeleteModal] = useFlag();
const [isReportModalOpen, openReportModal, closeReportModal] = useFlag();

View File

@ -1,7 +1,7 @@
import React, {
FC, useEffect, useState, memo, useMemo, useCallback,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { ApiChatBannedRights, MAIN_THREAD_ID } from '../../api/types';
import {
@ -169,7 +169,7 @@ const MiddleColumn: FC<StateProps> = ({
joinChannel,
sendBotCommand,
restartBot,
} = getDispatch();
} = getActions();
const { width: windowWidth } = useWindowSize();

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useEffect, useRef, useState,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import cycleRestrict from '../../util/cycleRestrict';
import { GlobalState, MessageListType } from '../../global/types';
@ -124,7 +124,7 @@ const MiddleHeader: FC<OwnProps & StateProps> = ({
loadPinnedMessages,
toggleLeftColumn,
exitMessageSelectMode,
} = getDispatch();
} = getActions();
const lang = useLang();
const isBackButtonActive = useRef(true);

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useEffect, useRef, useState, useLayoutEffect,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { ApiChat } from '../../api/types';
@ -43,7 +43,7 @@ const MobileSearchFooter: FC<StateProps> = ({
focusMessage,
closeLocalTextSearch,
openHistoryCalendar,
} = getDispatch();
} = getActions();
// eslint-disable-next-line no-null/no-null
const inputRef = useRef<HTMLInputElement>(null);

View File

@ -1,7 +1,7 @@
import React, {
FC, useCallback, memo, useMemo, useEffect, useState, useRef,
} from '../../lib/teact/teact';
import { getDispatch, getGlobal, withGlobal } from '../../modules';
import { getActions, getGlobal, withGlobal } from '../../modules';
import { ApiMessage } from '../../api/types';
import { LoadMoreDirection } from '../../types';
@ -49,7 +49,7 @@ const ReactorListModal: FC<OwnProps & StateProps> = ({
loadReactors,
closeReactorListModal,
openChat,
} = getDispatch();
} = getActions();
// No need for expensive global updates on users, so we avoid them
const usersById = getGlobal().users.byId;

View File

@ -1,7 +1,7 @@
import React, {
FC, useCallback, memo, useRef,
} from '../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../modules';
import { getActions, withGlobal } from '../../modules';
import { MessageListType } from '../../global/types';
import { MAIN_THREAD_ID } from '../../api/types';
@ -36,7 +36,7 @@ const ScrollDownButton: FC<OwnProps & StateProps> = ({
unreadCount,
withExtraShift,
}) => {
const { focusNextReply } = getDispatch();
const { focusNextReply } = getActions();
const lang = useLang();
// eslint-disable-next-line no-null/no-null

View File

@ -1,7 +1,7 @@
import React, {
FC, memo, useCallback, useState,
} from '../../lib/teact/teact';
import { withGlobal, getDispatch } from '../../modules';
import { withGlobal, getActions } from '../../modules';
import { ApiUser } from '../../api/types';
@ -31,7 +31,7 @@ const UserReportPanel: FC<OwnProps & StateProps> = ({ userId, user }) => {
reportSpam,
deleteChat,
toggleChatArchived,
} = getDispatch();
} = getActions();
const lang = useLang();
const [isBlockUserModalOpen, openBlockUserModal, closeBlockUserModal] = useFlag();

View File

@ -9,7 +9,7 @@ import Menu from '../../ui/Menu';
import BotCommand from './BotCommand';
import './BotCommandMenu.scss';
import { getDispatch } from '../../../modules';
import { getActions } from '../../../modules';
export type OwnProps = {
isOpen: boolean;
@ -20,7 +20,7 @@ export type OwnProps = {
const BotCommandMenu: FC<OwnProps> = ({
isOpen, botCommands, onClose,
}) => {
const { sendBotCommand } = getDispatch();
const { sendBotCommand } = getActions();
const [handleMouseEnter, handleMouseLeave] = useMouseInside(isOpen, onClose, undefined, IS_SINGLE_COLUMN_LAYOUT);

View File

@ -1,7 +1,7 @@
import React, {
FC, useCallback, useEffect, useRef, memo,
} from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { ApiBotCommand, ApiUser } from '../../../api/types';
@ -35,7 +35,7 @@ const BotCommandTooltip: FC<OwnProps & StateProps> = ({
onClick,
onClose,
}) => {
const { sendBotCommand } = getDispatch();
const { sendBotCommand } = getActions();
// eslint-disable-next-line no-null/no-null
const containerRef = useRef<HTMLDivElement>(null);

View File

@ -1,5 +1,5 @@
import React, { FC, memo, useEffect } from '../../../lib/teact/teact';
import { getDispatch, withGlobal } from '../../../modules';
import { getActions, withGlobal } from '../../../modules';
import { ApiMessage } from '../../../api/types';
@ -26,7 +26,7 @@ type StateProps = {
const BotKeyboardMenu: FC<OwnProps & StateProps> = ({
isOpen, message, onClose,
}) => {
const { clickInlineButton } = getDispatch();
const { clickInlineButton } = getActions();
const [handleMouseEnter, handleMouseLeave] = useMouseInside(isOpen, onClose);
const { isKeyboardSingleUse } = message || {};

Some files were not shown because too many files have changed in this diff Show More