[Refactoring] Finally get rid of deprecated openUserInfo
This commit is contained in:
parent
6edb4c3fab
commit
8bae7c9e82
@ -834,9 +834,9 @@ export async function requestThreadInfoUpdate({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function searchMessagesLocal({
|
export async function searchMessagesLocal({
|
||||||
chatOrUser, type, query, topMessageId, minDate, maxDate, ...pagination
|
chat, type, query, topMessageId, minDate, maxDate, ...pagination
|
||||||
}: {
|
}: {
|
||||||
chatOrUser: ApiChat | ApiUser;
|
chat: ApiChat;
|
||||||
type?: ApiMessageSearchType | ApiGlobalMessageSearchType;
|
type?: ApiMessageSearchType | ApiGlobalMessageSearchType;
|
||||||
query?: string;
|
query?: string;
|
||||||
topMessageId?: number;
|
topMessageId?: number;
|
||||||
@ -873,7 +873,7 @@ export async function searchMessagesLocal({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const result = await invokeRequest(new GramJs.messages.Search({
|
const result = await invokeRequest(new GramJs.messages.Search({
|
||||||
peer: buildInputPeer(chatOrUser.id, chatOrUser.accessHash),
|
peer: buildInputPeer(chat.id, chat.accessHash),
|
||||||
filter,
|
filter,
|
||||||
q: query || '',
|
q: query || '',
|
||||||
topMsgId: topMessageId,
|
topMsgId: topMessageId,
|
||||||
|
|||||||
@ -230,7 +230,7 @@ export async function fetchProfilePhotos(user?: ApiUser, chat?: ApiChat) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const result = await searchMessagesLocal({
|
const result = await searchMessagesLocal({
|
||||||
chatOrUser: chat!,
|
chat: chat!,
|
||||||
type: 'profilePhoto',
|
type: 'profilePhoto',
|
||||||
limit: PROFILE_PHOTOS_LIMIT,
|
limit: PROFILE_PHOTOS_LIMIT,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -16,13 +16,13 @@ type OwnProps = {
|
|||||||
const UserLink: FC<OwnProps> = ({
|
const UserLink: FC<OwnProps> = ({
|
||||||
className, sender, children,
|
className, sender, children,
|
||||||
}) => {
|
}) => {
|
||||||
const { openUserInfo } = getDispatch();
|
const { openChat } = getDispatch();
|
||||||
|
|
||||||
const handleClick = useCallback(() => {
|
const handleClick = useCallback(() => {
|
||||||
if (sender) {
|
if (sender) {
|
||||||
openUserInfo({ id: sender.id });
|
openChat({ id: sender.id });
|
||||||
}
|
}
|
||||||
}, [sender, openUserInfo]);
|
}, [sender, openChat]);
|
||||||
|
|
||||||
if (!sender) {
|
if (!sender) {
|
||||||
return children;
|
return children;
|
||||||
|
|||||||
@ -23,7 +23,7 @@ type StateProps = {
|
|||||||
const Contact: FC<OwnProps & StateProps> = ({
|
const Contact: FC<OwnProps & StateProps> = ({
|
||||||
contact, user, phoneCodeList,
|
contact, user, phoneCodeList,
|
||||||
}) => {
|
}) => {
|
||||||
const { openUserInfo } = getDispatch();
|
const { openChat } = getDispatch();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
firstName,
|
firstName,
|
||||||
@ -33,8 +33,8 @@ const Contact: FC<OwnProps & StateProps> = ({
|
|||||||
} = contact;
|
} = contact;
|
||||||
|
|
||||||
const handleClick = useCallback(() => {
|
const handleClick = useCallback(() => {
|
||||||
openUserInfo({ id: userId });
|
openChat({ id: userId });
|
||||||
}, [openUserInfo, userId]);
|
}, [openChat, userId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import React, { useCallback } from '../../../../lib/teact/teact';
|
import React, { useCallback } from '../../../../lib/teact/teact';
|
||||||
import { getDispatch } from '../../../../lib/teact/teactn';
|
import { getDispatch } from '../../../../lib/teact/teactn';
|
||||||
|
|
||||||
import { isUserId } from '../../../../modules/helpers';
|
|
||||||
import { IAlbum, MediaViewerOrigin } from '../../../../types';
|
import { IAlbum, MediaViewerOrigin } from '../../../../types';
|
||||||
import {
|
import {
|
||||||
ApiChat, ApiMessage, ApiUser, MAIN_THREAD_ID,
|
ApiChat, ApiMessage, ApiUser, MAIN_THREAD_ID,
|
||||||
@ -24,7 +23,7 @@ export default function useInnerHandlers(
|
|||||||
botSender?: ApiUser,
|
botSender?: ApiUser,
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
openUserInfo, openChat, showNotification, focusMessage, openMediaViewer, openAudioPlayer,
|
openChat, showNotification, focusMessage, openMediaViewer, openAudioPlayer,
|
||||||
markMessagesRead, cancelSendingMessage, sendPollVote, openForwardMenu, focusMessageInComments,
|
markMessagesRead, cancelSendingMessage, sendPollVote, openForwardMenu, focusMessageInComments,
|
||||||
} = getDispatch();
|
} = getDispatch();
|
||||||
|
|
||||||
@ -37,12 +36,8 @@ export default function useInnerHandlers(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isUserId(avatarPeer.id)) {
|
openChat({ id: avatarPeer.id });
|
||||||
openUserInfo({ id: avatarPeer.id });
|
}, [avatarPeer, openChat]);
|
||||||
} else {
|
|
||||||
openChat({ id: avatarPeer.id });
|
|
||||||
}
|
|
||||||
}, [avatarPeer, openUserInfo, openChat]);
|
|
||||||
|
|
||||||
const handleSenderClick = useCallback(() => {
|
const handleSenderClick = useCallback(() => {
|
||||||
if (!senderPeer) {
|
if (!senderPeer) {
|
||||||
@ -53,13 +48,11 @@ export default function useInnerHandlers(
|
|||||||
|
|
||||||
if (asForwarded && forwardInfo?.channelPostId) {
|
if (asForwarded && forwardInfo?.channelPostId) {
|
||||||
focusMessage({ chatId: senderPeer.id, messageId: forwardInfo.channelPostId });
|
focusMessage({ chatId: senderPeer.id, messageId: forwardInfo.channelPostId });
|
||||||
} else if (isUserId(senderPeer.id)) {
|
|
||||||
openUserInfo({ id: senderPeer.id });
|
|
||||||
} else {
|
} else {
|
||||||
openChat({ id: senderPeer.id });
|
openChat({ id: senderPeer.id });
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
asForwarded, focusMessage, forwardInfo, lang, openChat, openUserInfo, senderPeer, showNotification,
|
asForwarded, focusMessage, forwardInfo, lang, openChat, senderPeer, showNotification,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const handleViaBotClick = useCallback(() => {
|
const handleViaBotClick = useCallback(() => {
|
||||||
@ -67,8 +60,8 @@ export default function useInnerHandlers(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
openUserInfo({ id: botSender.id });
|
openChat({ id: botSender.id });
|
||||||
}, [botSender, openUserInfo]);
|
}, [botSender, openChat]);
|
||||||
|
|
||||||
const handleReplyClick = useCallback((): void => {
|
const handleReplyClick = useCallback((): void => {
|
||||||
focusMessage({
|
focusMessage({
|
||||||
|
|||||||
@ -65,7 +65,6 @@ import { useIntersectionObserver } from '../../hooks/useIntersectionObserver';
|
|||||||
|
|
||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
chatId: string;
|
chatId: string;
|
||||||
userId?: string;
|
|
||||||
profileState: ProfileState;
|
profileState: ProfileState;
|
||||||
onProfileStateChange: (state: ProfileState) => void;
|
onProfileStateChange: (state: ProfileState) => void;
|
||||||
};
|
};
|
||||||
@ -143,7 +142,6 @@ const Profile: FC<OwnProps & StateProps> = ({
|
|||||||
searchMediaMessagesLocal,
|
searchMediaMessagesLocal,
|
||||||
openMediaViewer,
|
openMediaViewer,
|
||||||
openAudioPlayer,
|
openAudioPlayer,
|
||||||
openUserInfo,
|
|
||||||
focusMessage,
|
focusMessage,
|
||||||
loadProfilePhotos,
|
loadProfilePhotos,
|
||||||
setNewChatMembersDialogState,
|
setNewChatMembersDialogState,
|
||||||
@ -222,8 +220,8 @@ const Profile: FC<OwnProps & StateProps> = ({
|
|||||||
}, [profileId, openAudioPlayer]);
|
}, [profileId, openAudioPlayer]);
|
||||||
|
|
||||||
const handleMemberClick = useCallback((id: string) => {
|
const handleMemberClick = useCallback((id: string) => {
|
||||||
openUserInfo({ id });
|
openChat({ id });
|
||||||
}, [openUserInfo]);
|
}, [openChat]);
|
||||||
|
|
||||||
const handleMessageFocus = useCallback((messageId: number) => {
|
const handleMessageFocus = useCallback((messageId: number) => {
|
||||||
focusMessage({ chatId: profileId, messageId });
|
focusMessage({ chatId: profileId, messageId });
|
||||||
@ -492,10 +490,9 @@ function buildInfiniteScrollItemSelector(resultType: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default memo(withGlobal<OwnProps>(
|
export default memo(withGlobal<OwnProps>(
|
||||||
(global, { chatId, userId }): StateProps => {
|
(global, { chatId }): StateProps => {
|
||||||
const chat = selectChat(global, chatId);
|
const chat = selectChat(global, chatId);
|
||||||
|
const chatMessages = selectChatMessages(global, chatId);
|
||||||
const chatMessages = selectChatMessages(global, userId || chatId);
|
|
||||||
const { currentType: mediaSearchType, resultsByType } = selectCurrentMediaSearch(global) || {};
|
const { currentType: mediaSearchType, resultsByType } = selectCurrentMediaSearch(global) || {};
|
||||||
const { foundIds } = (resultsByType && mediaSearchType && resultsByType[mediaSearchType]) || {};
|
const { foundIds } = (resultsByType && mediaSearchType && resultsByType[mediaSearchType]) || {};
|
||||||
|
|
||||||
@ -509,18 +506,13 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
const areMembersHidden = hasMembersTab && chat && chat.fullInfo && !chat.fullInfo.canViewMembers;
|
const areMembersHidden = hasMembersTab && chat && chat.fullInfo && !chat.fullInfo.canViewMembers;
|
||||||
const canAddMembers = hasMembersTab && chat && (getHasAdminRight(chat, 'inviteUsers') || chat.isCreator);
|
const canAddMembers = hasMembersTab && chat && (getHasAdminRight(chat, 'inviteUsers') || chat.isCreator);
|
||||||
const canDeleteMembers = hasMembersTab && chat && (getHasAdminRight(chat, 'banUsers') || chat.isCreator);
|
const canDeleteMembers = hasMembersTab && chat && (getHasAdminRight(chat, 'banUsers') || chat.isCreator);
|
||||||
|
|
||||||
const activeDownloadIds = selectActiveDownloadIds(global, chatId);
|
const activeDownloadIds = selectActiveDownloadIds(global, chatId);
|
||||||
|
|
||||||
let hasCommonChatsTab;
|
let hasCommonChatsTab;
|
||||||
let resolvedUserId;
|
let resolvedUserId;
|
||||||
let user;
|
let user;
|
||||||
if (userId) {
|
if (isUserId(chatId)) {
|
||||||
resolvedUserId = userId;
|
|
||||||
} else if (isUserId(chatId)) {
|
|
||||||
resolvedUserId = chatId;
|
resolvedUserId = chatId;
|
||||||
}
|
|
||||||
if (resolvedUserId) {
|
|
||||||
user = selectUser(global, resolvedUserId);
|
user = selectUser(global, resolvedUserId);
|
||||||
hasCommonChatsTab = user && !user.isSelf && !isUserBot(user);
|
hasCommonChatsTab = user && !user.isSelf && !isUserBot(user);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,7 +35,6 @@ type StateProps = {
|
|||||||
contentKey?: RightColumnContent;
|
contentKey?: RightColumnContent;
|
||||||
chatId?: string;
|
chatId?: string;
|
||||||
threadId?: number;
|
threadId?: number;
|
||||||
currentProfileUserId?: string;
|
|
||||||
isChatSelected: boolean;
|
isChatSelected: boolean;
|
||||||
shouldSkipHistoryAnimations?: boolean;
|
shouldSkipHistoryAnimations?: boolean;
|
||||||
nextManagementScreen?: ManagementScreens;
|
nextManagementScreen?: ManagementScreens;
|
||||||
@ -56,7 +55,6 @@ const RightColumn: FC<StateProps> = ({
|
|||||||
contentKey,
|
contentKey,
|
||||||
chatId,
|
chatId,
|
||||||
threadId,
|
threadId,
|
||||||
currentProfileUserId,
|
|
||||||
isChatSelected,
|
isChatSelected,
|
||||||
shouldSkipHistoryAnimations,
|
shouldSkipHistoryAnimations,
|
||||||
nextManagementScreen,
|
nextManagementScreen,
|
||||||
@ -64,7 +62,6 @@ const RightColumn: FC<StateProps> = ({
|
|||||||
const {
|
const {
|
||||||
toggleChatInfo,
|
toggleChatInfo,
|
||||||
toggleManagement,
|
toggleManagement,
|
||||||
openUserInfo,
|
|
||||||
closeLocalTextSearch,
|
closeLocalTextSearch,
|
||||||
setStickerSearchQuery,
|
setStickerSearchQuery,
|
||||||
setGifSearchQuery,
|
setGifSearchQuery,
|
||||||
@ -84,7 +81,7 @@ const RightColumn: FC<StateProps> = ({
|
|||||||
const isScrolledDown = profileState !== ProfileState.Profile;
|
const isScrolledDown = profileState !== ProfileState.Profile;
|
||||||
|
|
||||||
const isOpen = contentKey !== undefined;
|
const isOpen = contentKey !== undefined;
|
||||||
const isProfile = contentKey === RightColumnContent.ChatInfo || contentKey === RightColumnContent.UserInfo;
|
const isProfile = contentKey === RightColumnContent.ChatInfo;
|
||||||
const isSearch = contentKey === RightColumnContent.Search;
|
const isSearch = contentKey === RightColumnContent.Search;
|
||||||
const isManagement = contentKey === RightColumnContent.Management;
|
const isManagement = contentKey === RightColumnContent.Management;
|
||||||
const isStickerSearch = contentKey === RightColumnContent.StickerSearch;
|
const isStickerSearch = contentKey === RightColumnContent.StickerSearch;
|
||||||
@ -109,13 +106,6 @@ const RightColumn: FC<StateProps> = ({
|
|||||||
}
|
}
|
||||||
toggleChatInfo(undefined, { forceSyncOnIOs: true });
|
toggleChatInfo(undefined, { forceSyncOnIOs: true });
|
||||||
break;
|
break;
|
||||||
case RightColumnContent.UserInfo:
|
|
||||||
if (isScrolledDown && shouldScrollUp) {
|
|
||||||
setProfileState(ProfileState.Profile);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
openUserInfo({ id: undefined }, { forceSyncOnIOs: true });
|
|
||||||
break;
|
|
||||||
case RightColumnContent.Management: {
|
case RightColumnContent.Management: {
|
||||||
switch (managementScreen) {
|
switch (managementScreen) {
|
||||||
case ManagementScreens.Initial:
|
case ManagementScreens.Initial:
|
||||||
@ -175,7 +165,7 @@ const RightColumn: FC<StateProps> = ({
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
contentKey, isScrolledDown, toggleChatInfo, openUserInfo, closePollResults, setNewChatMembersDialogState,
|
contentKey, isScrolledDown, toggleChatInfo, closePollResults, setNewChatMembersDialogState,
|
||||||
managementScreen, toggleManagement, closeLocalTextSearch, setStickerSearchQuery, setGifSearchQuery,
|
managementScreen, toggleManagement, closeLocalTextSearch, setStickerSearchQuery, setGifSearchQuery,
|
||||||
setEditingExportedInvite, chatId, setOpenedInviteInfo,
|
setEditingExportedInvite, chatId, setOpenedInviteInfo,
|
||||||
]);
|
]);
|
||||||
@ -213,21 +203,18 @@ const RightColumn: FC<StateProps> = ({
|
|||||||
}, [isOverlaying]);
|
}, [isOverlaying]);
|
||||||
|
|
||||||
// We need to clear profile state and management screen state, when changing chats
|
// We need to clear profile state and management screen state, when changing chats
|
||||||
useLayoutEffectWithPrevDeps(([prevContentKey, prevChatId]) => {
|
useLayoutEffectWithPrevDeps(([prevChatId]) => {
|
||||||
if (
|
if (prevChatId !== chatId ) {
|
||||||
(prevContentKey === RightColumnContent.ChatInfo && contentKey === RightColumnContent.UserInfo)
|
|
||||||
|| (prevContentKey === RightColumnContent.UserInfo && contentKey === RightColumnContent.ChatInfo)
|
|
||||||
|| (prevChatId !== chatId)
|
|
||||||
) {
|
|
||||||
setProfileState(ProfileState.Profile);
|
setProfileState(ProfileState.Profile);
|
||||||
setManagementScreen(ManagementScreens.Initial);
|
setManagementScreen(ManagementScreens.Initial);
|
||||||
}
|
}
|
||||||
}, [contentKey, chatId]);
|
}, [chatId]);
|
||||||
|
|
||||||
useHistoryBack(isChatSelected && (contentKey === RightColumnContent.ChatInfo
|
useHistoryBack(isChatSelected && (
|
||||||
|| contentKey === RightColumnContent.UserInfo || contentKey === RightColumnContent.Management
|
contentKey === RightColumnContent.ChatInfo
|
||||||
|| contentKey === RightColumnContent.AddingMembers),
|
|| contentKey === RightColumnContent.Management
|
||||||
() => close(false), toggleChatInfo);
|
|| contentKey === RightColumnContent.AddingMembers
|
||||||
|
), () => close(false), toggleChatInfo);
|
||||||
|
|
||||||
// eslint-disable-next-line consistent-return
|
// eslint-disable-next-line consistent-return
|
||||||
function renderContent(isActive: boolean) {
|
function renderContent(isActive: boolean) {
|
||||||
@ -247,12 +234,10 @@ const RightColumn: FC<StateProps> = ({
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case RightColumnContent.ChatInfo:
|
case RightColumnContent.ChatInfo:
|
||||||
case RightColumnContent.UserInfo:
|
|
||||||
return (
|
return (
|
||||||
<Profile
|
<Profile
|
||||||
key={currentProfileUserId || chatId!}
|
key={chatId!}
|
||||||
chatId={chatId!}
|
chatId={chatId!}
|
||||||
userId={currentProfileUserId}
|
|
||||||
profileState={profileState}
|
profileState={profileState}
|
||||||
onProfileStateChange={setProfileState}
|
onProfileStateChange={setProfileState}
|
||||||
/>
|
/>
|
||||||
@ -331,7 +316,6 @@ export default memo(withGlobal(
|
|||||||
contentKey: selectRightColumnContentKey(global),
|
contentKey: selectRightColumnContentKey(global),
|
||||||
chatId,
|
chatId,
|
||||||
threadId,
|
threadId,
|
||||||
currentProfileUserId: global.users.selectedId,
|
|
||||||
isChatSelected: Boolean(chatId && areActiveChatsLoaded),
|
isChatSelected: Boolean(chatId && areActiveChatsLoaded),
|
||||||
shouldSkipHistoryAnimations: global.shouldSkipHistoryAnimations,
|
shouldSkipHistoryAnimations: global.shouldSkipHistoryAnimations,
|
||||||
nextManagementScreen,
|
nextManagementScreen,
|
||||||
|
|||||||
@ -38,7 +38,7 @@ const JoinRequest: FC<OwnProps & StateProps> = ({
|
|||||||
serverTimeOffset,
|
serverTimeOffset,
|
||||||
chatId,
|
chatId,
|
||||||
}) => {
|
}) => {
|
||||||
const { openUserInfo, hideChatJoinRequest } = getDispatch();
|
const { openChat, hideChatJoinRequest } = getDispatch();
|
||||||
|
|
||||||
const buildClassName = createClassNameBuilder('JoinRequest');
|
const buildClassName = createClassNameBuilder('JoinRequest');
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
@ -50,7 +50,7 @@ const JoinRequest: FC<OwnProps & StateProps> = ({
|
|||||||
? formatTime(lang, fixedDate) : formatHumanDate(lang, fixedDate, true, false, true);
|
? formatTime(lang, fixedDate) : formatHumanDate(lang, fixedDate, true, false, true);
|
||||||
|
|
||||||
const handleUserClick = () => {
|
const handleUserClick = () => {
|
||||||
openUserInfo({ id: userId });
|
openChat({ id: userId });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAcceptRequest = useCallback(() => {
|
const handleAcceptRequest = useCallback(() => {
|
||||||
|
|||||||
@ -62,7 +62,7 @@ const ManageGroupMembers: FC<OwnProps & StateProps> = ({
|
|||||||
onScreenSelect,
|
onScreenSelect,
|
||||||
onChatMemberSelect,
|
onChatMemberSelect,
|
||||||
}) => {
|
}) => {
|
||||||
const { openUserInfo, setUserSearchQuery, loadContactList } = getDispatch();
|
const { openChat, setUserSearchQuery, loadContactList } = getDispatch();
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
@ -126,9 +126,9 @@ const ManageGroupMembers: FC<OwnProps & StateProps> = ({
|
|||||||
onChatMemberSelect!(id, false);
|
onChatMemberSelect!(id, false);
|
||||||
onScreenSelect!(ManagementScreens.ChatNewAdminRights);
|
onScreenSelect!(ManagementScreens.ChatNewAdminRights);
|
||||||
} else {
|
} else {
|
||||||
openUserInfo({ id });
|
openChat({ id });
|
||||||
}
|
}
|
||||||
}, [noAdmins, onChatMemberSelect, onScreenSelect, openUserInfo]);
|
}, [noAdmins, onChatMemberSelect, onScreenSelect, openChat]);
|
||||||
|
|
||||||
const handleFilterChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleFilterChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
setUserSearchQuery({ query: e.target.value });
|
setUserSearchQuery({ query: e.target.value });
|
||||||
|
|||||||
@ -47,7 +47,7 @@ const ManageInviteInfo: FC<OwnProps & StateProps> = ({
|
|||||||
showNotification,
|
showNotification,
|
||||||
loadChatInviteImporters,
|
loadChatInviteImporters,
|
||||||
loadChatInviteRequesters,
|
loadChatInviteRequesters,
|
||||||
openUserInfo,
|
openChat,
|
||||||
} = getDispatch();
|
} = getDispatch();
|
||||||
|
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
@ -86,7 +86,7 @@ const ManageInviteInfo: FC<OwnProps & StateProps> = ({
|
|||||||
{importers.map((importer) => (
|
{importers.map((importer) => (
|
||||||
<ListItem
|
<ListItem
|
||||||
className="chat-item-clickable scroll-item small-icon"
|
className="chat-item-clickable scroll-item small-icon"
|
||||||
onClick={() => openUserInfo({ id: importer.userId })}
|
onClick={() => openChat({ id: importer.userId })}
|
||||||
>
|
>
|
||||||
<PrivateChatInfo
|
<PrivateChatInfo
|
||||||
userId={importer.userId}
|
userId={importer.userId}
|
||||||
@ -111,7 +111,7 @@ const ManageInviteInfo: FC<OwnProps & StateProps> = ({
|
|||||||
{requesters.map((requester) => (
|
{requesters.map((requester) => (
|
||||||
<ListItem
|
<ListItem
|
||||||
className="chat-item-clickable scroll-item small-icon"
|
className="chat-item-clickable scroll-item small-icon"
|
||||||
onClick={() => openUserInfo({ id: requester.userId })}
|
onClick={() => openChat({ id: requester.userId })}
|
||||||
>
|
>
|
||||||
<PrivateChatInfo
|
<PrivateChatInfo
|
||||||
userId={requester.userId}
|
userId={requester.userId}
|
||||||
@ -155,7 +155,7 @@ const ManageInviteInfo: FC<OwnProps & StateProps> = ({
|
|||||||
<p>{lang('LinkCreatedeBy')}</p>
|
<p>{lang('LinkCreatedeBy')}</p>
|
||||||
<ListItem
|
<ListItem
|
||||||
className="chat-item-clickable scroll-item small-icon"
|
className="chat-item-clickable scroll-item small-icon"
|
||||||
onClick={() => openUserInfo({ id: adminId })}
|
onClick={() => openChat({ id: adminId })}
|
||||||
>
|
>
|
||||||
<PrivateChatInfo
|
<PrivateChatInfo
|
||||||
userId={adminId}
|
userId={adminId}
|
||||||
|
|||||||
@ -263,7 +263,7 @@ function reduceShowChatInfo(global: GlobalState): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function reduceUsers(global: GlobalState): GlobalState['users'] {
|
function reduceUsers(global: GlobalState): GlobalState['users'] {
|
||||||
const { users: { byId, statusesById, selectedId } } = global;
|
const { users: { byId, statusesById } } = global;
|
||||||
const chatIds = (global.chats.listIds.active || []).slice(0, GLOBAL_STATE_CACHE_CHAT_LIST_LIMIT).filter(isUserId);
|
const chatIds = (global.chats.listIds.active || []).slice(0, GLOBAL_STATE_CACHE_CHAT_LIST_LIMIT).filter(isUserId);
|
||||||
const userIds = Object.keys(byId);
|
const userIds = Object.keys(byId);
|
||||||
const idsToSave = chatIds.concat(userIds).slice(0, GLOBAL_STATE_CACHE_USER_LIST_LIMIT);
|
const idsToSave = chatIds.concat(userIds).slice(0, GLOBAL_STATE_CACHE_USER_LIST_LIMIT);
|
||||||
@ -271,7 +271,6 @@ function reduceUsers(global: GlobalState): GlobalState['users'] {
|
|||||||
return {
|
return {
|
||||||
byId: pick(byId, idsToSave),
|
byId: pick(byId, idsToSave),
|
||||||
statusesById: pick(statusesById, idsToSave),
|
statusesById: pick(statusesById, idsToSave),
|
||||||
selectedId: window.innerWidth > MIN_SCREEN_WIDTH_FOR_STATIC_RIGHT_COLUMN ? selectedId : undefined,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -152,8 +152,6 @@ export type GlobalState = {
|
|||||||
users: {
|
users: {
|
||||||
byId: Record<string, ApiUser>;
|
byId: Record<string, ApiUser>;
|
||||||
statusesById: Record<string, ApiUserStatus>;
|
statusesById: Record<string, ApiUserStatus>;
|
||||||
// TODO Remove
|
|
||||||
selectedId?: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
chats: {
|
chats: {
|
||||||
@ -563,7 +561,7 @@ export type ActionTypes = (
|
|||||||
'togglePreHistoryHidden' | 'updateChatDefaultBannedRights' | 'updateChatMemberBannedRights' | 'updateChatAdmin' |
|
'togglePreHistoryHidden' | 'updateChatDefaultBannedRights' | 'updateChatMemberBannedRights' | 'updateChatAdmin' |
|
||||||
'acceptInviteConfirmation' |
|
'acceptInviteConfirmation' |
|
||||||
// users
|
// users
|
||||||
'loadFullUser' | 'openUserInfo' | 'loadNearestCountry' | 'loadTopUsers' | 'loadContactList' |
|
'loadFullUser' | 'loadNearestCountry' | 'loadTopUsers' | 'loadContactList' |
|
||||||
'loadCurrentUser' | 'updateProfile' | 'checkUsername' | 'addContact' | 'updateContact' |
|
'loadCurrentUser' | 'updateProfile' | 'checkUsername' | 'addContact' | 'updateContact' |
|
||||||
'deleteContact' | 'loadUser' | 'setUserSearchQuery' | 'loadCommonChats' |
|
'deleteContact' | 'loadUser' | 'setUserSearchQuery' | 'loadCommonChats' |
|
||||||
// chat creation
|
// chat creation
|
||||||
|
|||||||
@ -109,7 +109,7 @@ async function searchMessagesGlobal(
|
|||||||
|
|
||||||
if (chat) {
|
if (chat) {
|
||||||
const localResult = await callApi('searchMessagesLocal', {
|
const localResult = await callApi('searchMessagesLocal', {
|
||||||
chatOrUser: chat,
|
chat,
|
||||||
query,
|
query,
|
||||||
type,
|
type,
|
||||||
limit: GLOBAL_SEARCH_SLICE,
|
limit: GLOBAL_SEARCH_SLICE,
|
||||||
|
|||||||
@ -2,13 +2,12 @@ import {
|
|||||||
addReducer, getDispatch, getGlobal, setGlobal,
|
addReducer, getDispatch, getGlobal, setGlobal,
|
||||||
} from '../../../lib/teact/teactn';
|
} from '../../../lib/teact/teactn';
|
||||||
|
|
||||||
import { ApiChat, ApiUser, MAIN_THREAD_ID } from '../../../api/types';
|
import { ApiChat, MAIN_THREAD_ID } from '../../../api/types';
|
||||||
|
|
||||||
import { MESSAGE_SEARCH_SLICE, SHARED_MEDIA_SLICE } from '../../../config';
|
import { MESSAGE_SEARCH_SLICE, SHARED_MEDIA_SLICE } from '../../../config';
|
||||||
import { callApi } from '../../../api/gramjs';
|
import { callApi } from '../../../api/gramjs';
|
||||||
import {
|
import {
|
||||||
selectCurrentTextSearch,
|
selectCurrentTextSearch,
|
||||||
selectCurrentMediaSearchPeerId,
|
|
||||||
selectCurrentMediaSearch,
|
selectCurrentMediaSearch,
|
||||||
selectCurrentMessageList,
|
selectCurrentMessageList,
|
||||||
selectChat,
|
selectChat,
|
||||||
@ -45,13 +44,15 @@ addReducer('searchTextMessagesLocal', (global) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
addReducer('searchMediaMessagesLocal', (global) => {
|
addReducer('searchMediaMessagesLocal', (global) => {
|
||||||
const peerId = selectCurrentMediaSearchPeerId(global);
|
const { chatId } = selectCurrentMessageList(global) || {};
|
||||||
const chatOrUser = peerId
|
if (!chatId) {
|
||||||
? global.users.byId[peerId] || global.chats.byId[peerId]
|
return;
|
||||||
: undefined;
|
}
|
||||||
|
|
||||||
|
const chat = selectChat(global, chatId);
|
||||||
const currentSearch = selectCurrentMediaSearch(global);
|
const currentSearch = selectCurrentMediaSearch(global);
|
||||||
|
|
||||||
if (!chatOrUser || !currentSearch) {
|
if (!chat || !currentSearch) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +64,7 @@ addReducer('searchMediaMessagesLocal', (global) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void searchSharedMedia(chatOrUser, type, offsetId);
|
void searchSharedMedia(chat, type, offsetId);
|
||||||
});
|
});
|
||||||
|
|
||||||
addReducer('searchMessagesByDate', (global, actions, payload) => {
|
addReducer('searchMessagesByDate', (global, actions, payload) => {
|
||||||
@ -83,7 +84,7 @@ addReducer('searchMessagesByDate', (global, actions, payload) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function searchTextMessages(
|
async function searchTextMessages(
|
||||||
chatOrUser: ApiChat,
|
chat: ApiChat,
|
||||||
threadId: number,
|
threadId: number,
|
||||||
topMessageId?: number,
|
topMessageId?: number,
|
||||||
query?: string,
|
query?: string,
|
||||||
@ -94,7 +95,7 @@ async function searchTextMessages(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const result = await callApi('searchMessagesLocal', {
|
const result = await callApi('searchMessagesLocal', {
|
||||||
chatOrUser,
|
chat,
|
||||||
type: 'text',
|
type: 'text',
|
||||||
query,
|
query,
|
||||||
topMessageId,
|
topMessageId,
|
||||||
@ -122,19 +123,19 @@ async function searchTextMessages(
|
|||||||
|
|
||||||
global = addChats(global, buildCollectionByKey(chats, 'id'));
|
global = addChats(global, buildCollectionByKey(chats, 'id'));
|
||||||
global = addUsers(global, buildCollectionByKey(users, 'id'));
|
global = addUsers(global, buildCollectionByKey(users, 'id'));
|
||||||
global = addChatMessagesById(global, chatOrUser.id, byId);
|
global = addChatMessagesById(global, chat.id, byId);
|
||||||
global = updateLocalTextSearchResults(global, chatOrUser.id, threadId, newFoundIds, totalCount, nextOffsetId);
|
global = updateLocalTextSearchResults(global, chat.id, threadId, newFoundIds, totalCount, nextOffsetId);
|
||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function searchSharedMedia(
|
async function searchSharedMedia(
|
||||||
chatOrUser: ApiChat | ApiUser,
|
chat: ApiChat,
|
||||||
type: SharedMediaType,
|
type: SharedMediaType,
|
||||||
offsetId?: number,
|
offsetId?: number,
|
||||||
isBudgetPreload = false,
|
isBudgetPreload = false,
|
||||||
) {
|
) {
|
||||||
const result = await callApi('searchMessagesLocal', {
|
const result = await callApi('searchMessagesLocal', {
|
||||||
chatOrUser,
|
chat,
|
||||||
type,
|
type,
|
||||||
limit: SHARED_MEDIA_SLICE * 2,
|
limit: SHARED_MEDIA_SLICE * 2,
|
||||||
offsetId,
|
offsetId,
|
||||||
@ -160,12 +161,12 @@ async function searchSharedMedia(
|
|||||||
|
|
||||||
global = addChats(global, buildCollectionByKey(chats, 'id'));
|
global = addChats(global, buildCollectionByKey(chats, 'id'));
|
||||||
global = addUsers(global, buildCollectionByKey(users, 'id'));
|
global = addUsers(global, buildCollectionByKey(users, 'id'));
|
||||||
global = addChatMessagesById(global, chatOrUser.id, byId);
|
global = addChatMessagesById(global, chat.id, byId);
|
||||||
global = updateLocalMediaSearchResults(global, chatOrUser.id, type, newFoundIds, totalCount, nextOffsetId);
|
global = updateLocalMediaSearchResults(global, chat.id, type, newFoundIds, totalCount, nextOffsetId);
|
||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
|
|
||||||
if (!isBudgetPreload) {
|
if (!isBudgetPreload) {
|
||||||
searchSharedMedia(chatOrUser, type, nextOffsetId, true);
|
searchSharedMedia(chat, type, nextOffsetId, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,18 +1,6 @@
|
|||||||
import { addReducer } from '../../../lib/teact/teactn';
|
import { addReducer } from '../../../lib/teact/teactn';
|
||||||
|
|
||||||
import { GlobalState } from '../../../global/types';
|
import { updateUserSearch } from '../../reducers';
|
||||||
|
|
||||||
import { updateSelectedUserId, updateUserSearch } from '../../reducers';
|
|
||||||
|
|
||||||
addReducer('openUserInfo', (global, actions, payload) => {
|
|
||||||
const { id } = payload!;
|
|
||||||
|
|
||||||
actions.openChat({ id });
|
|
||||||
});
|
|
||||||
|
|
||||||
const clearSelectedUserId = (global: GlobalState) => updateSelectedUserId(global, undefined);
|
|
||||||
|
|
||||||
addReducer('openChat', clearSelectedUserId);
|
|
||||||
|
|
||||||
addReducer('setUserSearchQuery', (global, actions, payload) => {
|
addReducer('setUserSearchQuery', (global, actions, payload) => {
|
||||||
const { query } = payload!;
|
const { query } = payload!;
|
||||||
|
|||||||
@ -122,20 +122,6 @@ function getUpdatedUser(global: GlobalState, userId: string, userUpdate: Partial
|
|||||||
return updatedUser;
|
return updatedUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateSelectedUserId(global: GlobalState, selectedId?: string): GlobalState {
|
|
||||||
if (global.users.selectedId === selectedId) {
|
|
||||||
return global;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
...global,
|
|
||||||
users: {
|
|
||||||
...global.users,
|
|
||||||
selectedId,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function deleteContact(global: GlobalState, userId: string): GlobalState {
|
export function deleteContact(global: GlobalState, userId: string): GlobalState {
|
||||||
const { byId } = global.users;
|
const { byId } = global.users;
|
||||||
const { userIds } = global.contactList || {};
|
const { userIds } = global.contactList || {};
|
||||||
|
|||||||
@ -17,19 +17,11 @@ export function selectCurrentTextSearch(global: GlobalState) {
|
|||||||
return currentSearch;
|
return currentSearch;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function selectCurrentMediaSearchPeerId(global: GlobalState) {
|
|
||||||
const { byChatId } = global.localMediaSearch;
|
|
||||||
const { chatId } = selectCurrentMessageList(global) || {};
|
|
||||||
const currentProfileUserId = global.users.selectedId;
|
|
||||||
|
|
||||||
return currentProfileUserId && byChatId[currentProfileUserId] ? currentProfileUserId : chatId;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function selectCurrentMediaSearch(global: GlobalState) {
|
export function selectCurrentMediaSearch(global: GlobalState) {
|
||||||
const peerId = selectCurrentMediaSearchPeerId(global);
|
const { chatId } = selectCurrentMessageList(global) || {};
|
||||||
if (!peerId) {
|
if (!chatId) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return global.localMediaSearch.byChatId[peerId];
|
return global.localMediaSearch.byChatId[chatId];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,8 +4,7 @@ import { NewChatMembersProgress, RightColumnContent } from '../../types';
|
|||||||
import { getSystemTheme, IS_SINGLE_COLUMN_LAYOUT } from '../../util/environment';
|
import { getSystemTheme, IS_SINGLE_COLUMN_LAYOUT } from '../../util/environment';
|
||||||
import { selectCurrentMessageList, selectIsPollResultsOpen } from './messages';
|
import { selectCurrentMessageList, selectIsPollResultsOpen } from './messages';
|
||||||
import { selectCurrentTextSearch } from './localSearch';
|
import { selectCurrentTextSearch } from './localSearch';
|
||||||
import { selectCurrentStickerSearch, selectCurrentGifSearch } from './symbols';
|
import { selectCurrentGifSearch, selectCurrentStickerSearch } from './symbols';
|
||||||
import { selectAreActiveChatsLoaded } from './chats';
|
|
||||||
import { selectCurrentManagement } from './management';
|
import { selectCurrentManagement } from './management';
|
||||||
|
|
||||||
export function selectIsMediaViewerOpen(global: GlobalState) {
|
export function selectIsMediaViewerOpen(global: GlobalState) {
|
||||||
@ -14,42 +13,19 @@ export function selectIsMediaViewerOpen(global: GlobalState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function selectRightColumnContentKey(global: GlobalState) {
|
export function selectRightColumnContentKey(global: GlobalState) {
|
||||||
const {
|
return selectIsPollResultsOpen(global) ? (
|
||||||
users,
|
|
||||||
isChatInfoShown,
|
|
||||||
newChatMembersProgress,
|
|
||||||
} = global;
|
|
||||||
|
|
||||||
const isAddingChatMembersShown = newChatMembersProgress !== NewChatMembersProgress.Closed;
|
|
||||||
const isPollResults = selectIsPollResultsOpen(global);
|
|
||||||
const isSearch = Boolean(!IS_SINGLE_COLUMN_LAYOUT && selectCurrentTextSearch(global));
|
|
||||||
const isManagement = selectCurrentManagement(global);
|
|
||||||
const stickerSearch = selectCurrentStickerSearch(global);
|
|
||||||
const isStickerSearch = stickerSearch.query !== undefined;
|
|
||||||
const gifSearch = selectCurrentGifSearch(global);
|
|
||||||
const isGifSearch = gifSearch.query !== undefined;
|
|
||||||
const { chatId: currentChatId } = selectCurrentMessageList(global) || {};
|
|
||||||
const currentProfileUserId = users.selectedId;
|
|
||||||
const areActiveChatsLoaded = selectAreActiveChatsLoaded(global);
|
|
||||||
const isUserInfo = Boolean(currentProfileUserId && areActiveChatsLoaded);
|
|
||||||
const isChatShown = Boolean(currentChatId && areActiveChatsLoaded);
|
|
||||||
const isChatInfo = isChatShown && isChatInfoShown;
|
|
||||||
|
|
||||||
return isPollResults ? (
|
|
||||||
RightColumnContent.PollResults
|
RightColumnContent.PollResults
|
||||||
) : isSearch ? (
|
) : !IS_SINGLE_COLUMN_LAYOUT && selectCurrentTextSearch(global) ? (
|
||||||
RightColumnContent.Search
|
RightColumnContent.Search
|
||||||
) : isManagement ? (
|
) : selectCurrentManagement(global) ? (
|
||||||
RightColumnContent.Management
|
RightColumnContent.Management
|
||||||
) : isStickerSearch ? (
|
) : selectCurrentStickerSearch(global).query !== undefined ? (
|
||||||
RightColumnContent.StickerSearch
|
RightColumnContent.StickerSearch
|
||||||
) : isGifSearch ? (
|
) : selectCurrentGifSearch(global).query !== undefined ? (
|
||||||
RightColumnContent.GifSearch
|
RightColumnContent.GifSearch
|
||||||
) : isAddingChatMembersShown ? (
|
) : global.newChatMembersProgress !== NewChatMembersProgress.Closed ? (
|
||||||
RightColumnContent.AddingMembers
|
RightColumnContent.AddingMembers
|
||||||
) : isUserInfo ? (
|
) : global.isChatInfoShown && selectCurrentMessageList(global) ? (
|
||||||
RightColumnContent.UserInfo
|
|
||||||
) : isChatInfo ? (
|
|
||||||
RightColumnContent.ChatInfo
|
RightColumnContent.ChatInfo
|
||||||
) : undefined;
|
) : undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -234,7 +234,6 @@ export enum GlobalSearchContent {
|
|||||||
|
|
||||||
export enum RightColumnContent {
|
export enum RightColumnContent {
|
||||||
ChatInfo,
|
ChatInfo,
|
||||||
UserInfo,
|
|
||||||
Search,
|
Search,
|
||||||
Management,
|
Management,
|
||||||
StickerSearch,
|
StickerSearch,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user