Middle Header Menu: Open discussion (#1438)
This commit is contained in:
parent
0c9fe4643a
commit
61a8ec1d75
@ -381,6 +381,20 @@ async function getFullChannelInfo(
|
|||||||
) || {};
|
) || {};
|
||||||
const botCommands = botInfo ? buildApiChatBotCommands(botInfo) : undefined;
|
const botCommands = botInfo ? buildApiChatBotCommands(botInfo) : undefined;
|
||||||
|
|
||||||
|
if (result?.chats?.length > 1) {
|
||||||
|
updateLocalDb(result);
|
||||||
|
|
||||||
|
const [, mtpLinkedChat] = result.chats;
|
||||||
|
const chat = buildApiChatFromPreview(mtpLinkedChat, undefined, true);
|
||||||
|
if (chat) {
|
||||||
|
onUpdate({
|
||||||
|
'@type': 'updateChat',
|
||||||
|
id: chat.id,
|
||||||
|
chat,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fullInfo: {
|
fullInfo: {
|
||||||
about,
|
about,
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import DeleteChatModal from '../common/DeleteChatModal';
|
|||||||
import './HeaderMenuContainer.scss';
|
import './HeaderMenuContainer.scss';
|
||||||
|
|
||||||
type DispatchProps = Pick<GlobalActions, (
|
type DispatchProps = Pick<GlobalActions, (
|
||||||
'updateChatMutedState' | 'enterMessageSelectMode' | 'sendBotCommand' | 'restartBot'
|
'updateChatMutedState' | 'enterMessageSelectMode' | 'sendBotCommand' | 'restartBot' | 'openLinkedChat'
|
||||||
)>;
|
)>;
|
||||||
|
|
||||||
export type OwnProps = {
|
export type OwnProps = {
|
||||||
@ -49,6 +49,7 @@ type StateProps = {
|
|||||||
isPrivate?: boolean;
|
isPrivate?: boolean;
|
||||||
isMuted?: boolean;
|
isMuted?: boolean;
|
||||||
canDeleteChat?: boolean;
|
canDeleteChat?: boolean;
|
||||||
|
hasLinkedChat?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const HeaderMenuContainer: FC<OwnProps & StateProps & DispatchProps> = ({
|
const HeaderMenuContainer: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||||
@ -66,6 +67,7 @@ const HeaderMenuContainer: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
isPrivate,
|
isPrivate,
|
||||||
isMuted,
|
isMuted,
|
||||||
canDeleteChat,
|
canDeleteChat,
|
||||||
|
hasLinkedChat,
|
||||||
onSubscribeChannel,
|
onSubscribeChannel,
|
||||||
onSearchClick,
|
onSearchClick,
|
||||||
onClose,
|
onClose,
|
||||||
@ -74,6 +76,7 @@ const HeaderMenuContainer: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
enterMessageSelectMode,
|
enterMessageSelectMode,
|
||||||
sendBotCommand,
|
sendBotCommand,
|
||||||
restartBot,
|
restartBot,
|
||||||
|
openLinkedChat,
|
||||||
}) => {
|
}) => {
|
||||||
const [isMenuOpen, setIsMenuOpen] = useState(true);
|
const [isMenuOpen, setIsMenuOpen] = useState(true);
|
||||||
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
||||||
@ -109,6 +112,11 @@ const HeaderMenuContainer: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
closeMenu();
|
closeMenu();
|
||||||
}, [chatId, closeMenu, isMuted, updateChatMutedState]);
|
}, [chatId, closeMenu, isMuted, updateChatMutedState]);
|
||||||
|
|
||||||
|
const handleLinkedChatClick = useCallback(() => {
|
||||||
|
openLinkedChat({ id: chatId });
|
||||||
|
closeMenu();
|
||||||
|
}, [chatId, closeMenu, openLinkedChat]);
|
||||||
|
|
||||||
const handleSubscribe = useCallback(() => {
|
const handleSubscribe = useCallback(() => {
|
||||||
onSubscribeChannel();
|
onSubscribeChannel();
|
||||||
closeMenu();
|
closeMenu();
|
||||||
@ -181,6 +189,14 @@ const HeaderMenuContainer: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
{lang(isMuted ? 'ChatsUnmute' : 'ChatsMute')}
|
{lang(isMuted ? 'ChatsUnmute' : 'ChatsMute')}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
)}
|
)}
|
||||||
|
{hasLinkedChat && (
|
||||||
|
<MenuItem
|
||||||
|
icon="comments"
|
||||||
|
onClick={handleLinkedChatClick}
|
||||||
|
>
|
||||||
|
{lang('ViewDiscussion')}
|
||||||
|
</MenuItem>
|
||||||
|
)}
|
||||||
<MenuItem
|
<MenuItem
|
||||||
icon="select"
|
icon="select"
|
||||||
onClick={handleSelectMessages}
|
onClick={handleSelectMessages}
|
||||||
@ -223,6 +239,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
isMuted: selectIsChatMuted(chat, selectNotifySettings(global), selectNotifyExceptions(global)),
|
isMuted: selectIsChatMuted(chat, selectNotifySettings(global), selectNotifyExceptions(global)),
|
||||||
isPrivate: isChatPrivate(chat.id),
|
isPrivate: isChatPrivate(chat.id),
|
||||||
canDeleteChat: getCanDeleteChat(chat),
|
canDeleteChat: getCanDeleteChat(chat),
|
||||||
|
hasLinkedChat: Boolean(chat?.fullInfo?.linkedChatId),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
(setGlobal, actions): DispatchProps => pick(actions, [
|
(setGlobal, actions): DispatchProps => pick(actions, [
|
||||||
@ -230,5 +247,6 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
'enterMessageSelectMode',
|
'enterMessageSelectMode',
|
||||||
'sendBotCommand',
|
'sendBotCommand',
|
||||||
'restartBot',
|
'restartBot',
|
||||||
|
'openLinkedChat',
|
||||||
]),
|
]),
|
||||||
)(HeaderMenuContainer));
|
)(HeaderMenuContainer));
|
||||||
|
|||||||
@ -452,7 +452,7 @@ export type ActionTypes = (
|
|||||||
'setAuthPhoneNumber' | 'setAuthCode' | 'setAuthPassword' | 'signUp' | 'returnToAuthPhoneNumber' | 'signOut' |
|
'setAuthPhoneNumber' | 'setAuthCode' | 'setAuthPassword' | 'signUp' | 'returnToAuthPhoneNumber' | 'signOut' |
|
||||||
'setAuthRememberMe' | 'clearAuthError' | 'uploadProfilePhoto' | 'goToAuthQrCode' | 'clearCache' |
|
'setAuthRememberMe' | 'clearAuthError' | 'uploadProfilePhoto' | 'goToAuthQrCode' | 'clearCache' |
|
||||||
// chats
|
// chats
|
||||||
'preloadTopChatMessages' | 'loadChats' | 'loadMoreChats' | 'openChat' | 'openChatWithInfo' |
|
'preloadTopChatMessages' | 'loadChats' | 'loadMoreChats' | 'openChat' | 'openChatWithInfo' | 'openLinkedChat' |
|
||||||
'openSupportChat' | 'openTipsChat' |
|
'openSupportChat' | 'openTipsChat' |
|
||||||
'loadFullChat' | 'loadTopChats' | 'requestChatUpdate' | 'updateChatMutedState' |
|
'loadFullChat' | 'loadTopChats' | 'requestChatUpdate' | 'updateChatMutedState' |
|
||||||
'joinChannel' | 'leaveChannel' | 'deleteChannel' | 'toggleChatPinned' | 'toggleChatArchived' | 'toggleChatUnread' |
|
'joinChannel' | 'leaveChannel' | 'deleteChannel' | 'toggleChatPinned' | 'toggleChatArchived' | 'toggleChatUnread' |
|
||||||
|
|||||||
@ -124,6 +124,22 @@ addReducer('openChat', (global, actions, payload) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
addReducer('openLinkedChat', (global, actions, payload) => {
|
||||||
|
const { id } = payload!;
|
||||||
|
const chat = selectChat(global, id);
|
||||||
|
if (!chat) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
const chatFullInfo = await callApi('fetchFullChat', chat);
|
||||||
|
|
||||||
|
if (chatFullInfo?.fullInfo?.linkedChatId) {
|
||||||
|
actions.openChat({ id: chatFullInfo.fullInfo.linkedChatId });
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
});
|
||||||
|
|
||||||
addReducer('openSupportChat', (global, actions) => {
|
addReducer('openSupportChat', (global, actions) => {
|
||||||
const chat = selectSupportChat(global);
|
const chat = selectSupportChat(global);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user