Forums: Various fixes (#2425)
This commit is contained in:
parent
cdad1bc867
commit
aeb016dc7c
@ -125,7 +125,6 @@ const Chat: FC<OwnProps & StateProps> = ({
|
|||||||
openChat,
|
openChat,
|
||||||
focusLastMessage,
|
focusLastMessage,
|
||||||
loadTopics,
|
loadTopics,
|
||||||
openForumPanel,
|
|
||||||
} = getActions();
|
} = getActions();
|
||||||
|
|
||||||
const { isMobile } = useAppLayout();
|
const { isMobile } = useAppLayout();
|
||||||
@ -156,17 +155,12 @@ const Chat: FC<OwnProps & StateProps> = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleClick = useCallback(() => {
|
const handleClick = useCallback(() => {
|
||||||
if (isForum) {
|
|
||||||
openForumPanel({ chatId });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
openChat({ id: chatId, shouldReplaceHistory: true }, { forceOnHeavyAnimation: true });
|
openChat({ id: chatId, shouldReplaceHistory: true }, { forceOnHeavyAnimation: true });
|
||||||
|
|
||||||
if (isSelected && canScrollDown) {
|
if (isSelected && canScrollDown) {
|
||||||
focusLastMessage();
|
focusLastMessage();
|
||||||
}
|
}
|
||||||
}, [isForum, openChat, chatId, isSelected, canScrollDown, openForumPanel, focusLastMessage]);
|
}, [openChat, chatId, isSelected, canScrollDown, focusLastMessage]);
|
||||||
|
|
||||||
const handleDragEnter = useCallback((e) => {
|
const handleDragEnter = useCallback((e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import {
|
|||||||
LIGHT_THEME_BG_COLOR,
|
LIGHT_THEME_BG_COLOR,
|
||||||
ANIMATION_LEVEL_MIN,
|
ANIMATION_LEVEL_MIN,
|
||||||
SUPPORTED_IMAGE_CONTENT_TYPES,
|
SUPPORTED_IMAGE_CONTENT_TYPES,
|
||||||
|
GENERAL_TOPIC_ID,
|
||||||
} from '../../config';
|
} from '../../config';
|
||||||
import { MASK_IMAGE_DISABLED } from '../../util/environment';
|
import { MASK_IMAGE_DISABLED } from '../../util/environment';
|
||||||
import { DropAreaState } from './composer/DropArea';
|
import { DropAreaState } from './composer/DropArea';
|
||||||
@ -644,7 +645,9 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
const canStartBot = !canRestartBot && isBotNotStarted;
|
const canStartBot = !canRestartBot && isBotNotStarted;
|
||||||
const shouldLoadFullChat = Boolean(chat && isChatGroup(chat) && !chat.fullInfo && lastSyncTime);
|
const shouldLoadFullChat = Boolean(chat && isChatGroup(chat) && !chat.fullInfo && lastSyncTime);
|
||||||
const replyingToId = selectReplyingToId(global, chatId, threadId);
|
const replyingToId = selectReplyingToId(global, chatId, threadId);
|
||||||
const shouldBlockBeforeReply = chat?.isForum ? (threadId === MAIN_THREAD_ID && !replyingToId) : false;
|
const shouldBlockSendInForum = chat?.isForum
|
||||||
|
? threadId === MAIN_THREAD_ID && !replyingToId && (chat.topics?.[GENERAL_TOPIC_ID]?.isClosed)
|
||||||
|
: false;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
@ -657,10 +660,9 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
areChatSettingsLoaded: Boolean(chat?.settings),
|
areChatSettingsLoaded: Boolean(chat?.settings),
|
||||||
canPost: !isPinnedMessageList
|
canPost: !isPinnedMessageList
|
||||||
&& (!chat || canPost)
|
&& (!chat || canPost)
|
||||||
&& !(isScheduledMessageList && chat?.isForum && threadId === MAIN_THREAD_ID)
|
|
||||||
&& !isBotNotStarted
|
&& !isBotNotStarted
|
||||||
&& !(shouldJoinToSend && chat?.isNotJoined)
|
&& !(shouldJoinToSend && chat?.isNotJoined)
|
||||||
&& !shouldBlockBeforeReply,
|
&& !shouldBlockSendInForum,
|
||||||
isPinnedMessageList,
|
isPinnedMessageList,
|
||||||
isScheduledMessageList,
|
isScheduledMessageList,
|
||||||
currentUserBannedRights: chat?.currentUserBannedRights,
|
currentUserBannedRights: chat?.currentUserBannedRights,
|
||||||
|
|||||||
@ -180,7 +180,9 @@ const MiddleHeader: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
const handlePinnedMessageClick = useCallback((): void => {
|
const handlePinnedMessageClick = useCallback((): void => {
|
||||||
if (pinnedMessage) {
|
if (pinnedMessage) {
|
||||||
focusMessage({ chatId: pinnedMessage.chatId, threadId, messageId: pinnedMessage.id });
|
focusMessage({
|
||||||
|
chatId: pinnedMessage.chatId, threadId, messageId: pinnedMessage.id, noForumTopicPanel: true,
|
||||||
|
});
|
||||||
|
|
||||||
const newIndex = cycleRestrict(pinnedMessagesCount || 1, pinnedMessageIndex + 1);
|
const newIndex = cycleRestrict(pinnedMessagesCount || 1, pinnedMessageIndex + 1);
|
||||||
setPinnedMessageIndex(newIndex);
|
setPinnedMessageIndex(newIndex);
|
||||||
|
|||||||
@ -1081,7 +1081,9 @@ const Composer: FC<OwnProps & StateProps> = ({
|
|||||||
}, [closeBotCommandMenu, closeSymbolMenu, openSendAsMenu, isMobile]);
|
}, [closeBotCommandMenu, closeSymbolMenu, openSendAsMenu, isMobile]);
|
||||||
|
|
||||||
const handleAllScheduledClick = useCallback(() => {
|
const handleAllScheduledClick = useCallback(() => {
|
||||||
openChat({ id: chatId, threadId, type: 'scheduled' });
|
openChat({
|
||||||
|
id: chatId, threadId, type: 'scheduled', noForumTopicPanel: true,
|
||||||
|
});
|
||||||
}, [openChat, chatId, threadId]);
|
}, [openChat, chatId, threadId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@ -118,7 +118,7 @@ const ComposerEmbeddedMessage: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
const handleMessageClick = useCallback((): void => {
|
const handleMessageClick = useCallback((): void => {
|
||||||
if (isForwarding) return;
|
if (isForwarding) return;
|
||||||
focusMessage({ chatId: message!.chatId, messageId: message!.id });
|
focusMessage({ chatId: message!.chatId, messageId: message!.id, noForumTopicPanel: true });
|
||||||
}, [focusMessage, isForwarding, message]);
|
}, [focusMessage, isForwarding, message]);
|
||||||
|
|
||||||
const handleClearClick = useCallback((e: React.MouseEvent<HTMLButtonElement, MouseEvent>): void => {
|
const handleClearClick = useCallback((e: React.MouseEvent<HTMLButtonElement, MouseEvent>): void => {
|
||||||
|
|||||||
@ -31,7 +31,7 @@ import { AudioOrigin } from '../../../types';
|
|||||||
import { MAIN_THREAD_ID } from '../../../api/types';
|
import { MAIN_THREAD_ID } from '../../../api/types';
|
||||||
|
|
||||||
import { IS_ANDROID, IS_TOUCH_ENV } from '../../../util/environment';
|
import { IS_ANDROID, IS_TOUCH_ENV } from '../../../util/environment';
|
||||||
import { EMOJI_STATUS_LOOP_LIMIT } from '../../../config';
|
import { EMOJI_STATUS_LOOP_LIMIT, GENERAL_TOPIC_ID } from '../../../config';
|
||||||
import {
|
import {
|
||||||
selectChat,
|
selectChat,
|
||||||
selectChatMessage,
|
selectChatMessage,
|
||||||
@ -1285,8 +1285,9 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
|
|
||||||
const hasUnreadReaction = chat?.unreadReactions?.includes(message.id);
|
const hasUnreadReaction = chat?.unreadReactions?.includes(message.id);
|
||||||
|
|
||||||
const messageTopic = threadId === MAIN_THREAD_ID ? selectTopicFromMessage(global, message) : undefined;
|
|
||||||
const hasTopicChip = threadId === MAIN_THREAD_ID && chat?.isForum && isFirstInGroup;
|
const hasTopicChip = threadId === MAIN_THREAD_ID && chat?.isForum && isFirstInGroup;
|
||||||
|
const messageTopic = hasTopicChip ? (selectTopicFromMessage(global, message) || chat?.topics?.[GENERAL_TOPIC_ID])
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
theme: selectTheme(global),
|
theme: selectTheme(global),
|
||||||
|
|||||||
@ -73,6 +73,7 @@ export default function useInnerHandlers(
|
|||||||
threadId,
|
threadId,
|
||||||
messageId: replyToMessageId!,
|
messageId: replyToMessageId!,
|
||||||
replyMessageId: isChatWithRepliesBot && replyToChatId ? undefined : messageId,
|
replyMessageId: isChatWithRepliesBot && replyToChatId ? undefined : messageId,
|
||||||
|
noForumTopicPanel: true,
|
||||||
});
|
});
|
||||||
}, [focusMessage, isChatWithRepliesBot, replyToChatId, chatId, threadId, replyToMessageId, messageId]);
|
}, [focusMessage, isChatWithRepliesBot, replyToChatId, chatId, threadId, replyToMessageId, messageId]);
|
||||||
|
|
||||||
|
|||||||
@ -116,7 +116,7 @@ addActionHandler('preloadTopChatMessages', async (global, actions): Promise<void
|
|||||||
|
|
||||||
addActionHandler('openChat', (global, actions, payload): ActionReturnType => {
|
addActionHandler('openChat', (global, actions, payload): ActionReturnType => {
|
||||||
const {
|
const {
|
||||||
id, threadId = MAIN_THREAD_ID, noForumTopicPanel, tabId = getCurrentTabId(),
|
id, threadId = MAIN_THREAD_ID,
|
||||||
} = payload;
|
} = payload;
|
||||||
if (!id) {
|
if (!id) {
|
||||||
return;
|
return;
|
||||||
@ -137,10 +137,6 @@ addActionHandler('openChat', (global, actions, payload): ActionReturnType => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chat?.isForum && !noForumTopicPanel) {
|
|
||||||
actions.openForumPanel({ chatId: id, tabId });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!chat) {
|
if (!chat) {
|
||||||
if (id === currentUserId) {
|
if (id === currentUserId) {
|
||||||
void callApi('fetchChat', { type: 'self' });
|
void callApi('fetchChat', { type: 'self' });
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { MAIN_THREAD_ID } from '../../../api/types';
|
|||||||
import {
|
import {
|
||||||
exitMessageSelectMode, replaceTabThreadParam, updateCurrentMessageList,
|
exitMessageSelectMode, replaceTabThreadParam, updateCurrentMessageList,
|
||||||
} from '../../reducers';
|
} from '../../reducers';
|
||||||
import { selectCurrentMessageList, selectTabState } from '../../selectors';
|
import { selectChat, selectCurrentMessageList, selectTabState } from '../../selectors';
|
||||||
import { closeLocalTextSearch } from './localSearch';
|
import { closeLocalTextSearch } from './localSearch';
|
||||||
import type { ActionReturnType } from '../../types';
|
import type { ActionReturnType } from '../../types';
|
||||||
import { updateTabState } from '../../reducers/tabs';
|
import { updateTabState } from '../../reducers/tabs';
|
||||||
@ -18,6 +18,7 @@ addActionHandler('openChat', (global, actions, payload): ActionReturnType => {
|
|||||||
threadId = MAIN_THREAD_ID,
|
threadId = MAIN_THREAD_ID,
|
||||||
type = 'thread',
|
type = 'thread',
|
||||||
shouldReplaceHistory = false,
|
shouldReplaceHistory = false,
|
||||||
|
noForumTopicPanel,
|
||||||
tabId = getCurrentTabId(),
|
tabId = getCurrentTabId(),
|
||||||
} = payload;
|
} = payload;
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ addActionHandler('openChat', (global, actions, payload): ActionReturnType => {
|
|||||||
|
|
||||||
const tabState = selectTabState(global, tabId);
|
const tabState = selectTabState(global, tabId);
|
||||||
if (tabState.premiumModal?.promo && tabState.premiumModal?.isOpen) {
|
if (tabState.premiumModal?.promo && tabState.premiumModal?.isOpen) {
|
||||||
return updateTabState(global, {
|
global = updateTabState(global, {
|
||||||
premiumModal: {
|
premiumModal: {
|
||||||
...tabState.premiumModal,
|
...tabState.premiumModal,
|
||||||
isOpen: false,
|
isOpen: false,
|
||||||
@ -55,8 +56,14 @@ addActionHandler('openChat', (global, actions, payload): ActionReturnType => {
|
|||||||
}, tabId);
|
}, tabId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id && id !== selectTabState(global, tabId).forumPanelChatId) {
|
if (id) {
|
||||||
actions.closeForumPanel({ tabId });
|
const chat = selectChat(global, id);
|
||||||
|
|
||||||
|
if (chat?.isForum && !noForumTopicPanel) {
|
||||||
|
actions.openForumPanel({ chatId: id!, tabId });
|
||||||
|
} else if (id !== selectTabState(global, tabId).forumPanelChatId) {
|
||||||
|
actions.closeForumPanel({ tabId });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return updateCurrentMessageList(global, id, threadId, type, shouldReplaceHistory, tabId);
|
return updateCurrentMessageList(global, id, threadId, type, shouldReplaceHistory, tabId);
|
||||||
|
|||||||
@ -303,7 +303,7 @@ addActionHandler('closePollResults', (global, actions, payload): ActionReturnTyp
|
|||||||
});
|
});
|
||||||
|
|
||||||
addActionHandler('focusLastMessage', (global, actions, payload): ActionReturnType => {
|
addActionHandler('focusLastMessage', (global, actions, payload): ActionReturnType => {
|
||||||
const { noForumTopicPanel, tabId = getCurrentTabId() } = payload || {};
|
const { tabId = getCurrentTabId() } = payload || {};
|
||||||
const currentMessageList = selectCurrentMessageList(global, tabId);
|
const currentMessageList = selectCurrentMessageList(global, tabId);
|
||||||
if (!currentMessageList) {
|
if (!currentMessageList) {
|
||||||
return;
|
return;
|
||||||
@ -331,7 +331,7 @@ addActionHandler('focusLastMessage', (global, actions, payload): ActionReturnTyp
|
|||||||
threadId,
|
threadId,
|
||||||
messageId: lastMessageId,
|
messageId: lastMessageId,
|
||||||
noHighlight: true,
|
noHighlight: true,
|
||||||
noForumTopicPanel,
|
noForumTopicPanel: true,
|
||||||
tabId,
|
tabId,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -348,7 +348,7 @@ addActionHandler('focusNextReply', (global, actions, payload): ActionReturnType
|
|||||||
const replyStack = selectReplyStack(global, chatId, threadId, tabId);
|
const replyStack = selectReplyStack(global, chatId, threadId, tabId);
|
||||||
|
|
||||||
if (!replyStack || replyStack.length === 0) {
|
if (!replyStack || replyStack.length === 0) {
|
||||||
actions.focusLastMessage({ noForumTopicPanel: true, tabId });
|
actions.focusLastMessage({ tabId });
|
||||||
} else {
|
} else {
|
||||||
const messageId = replyStack.pop();
|
const messageId = replyStack.pop();
|
||||||
|
|
||||||
|
|||||||
@ -274,7 +274,7 @@ export function getForumComposerPlaceholder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (threadId === MAIN_THREAD_ID) {
|
if (threadId === MAIN_THREAD_ID) {
|
||||||
if (isReplying) return undefined;
|
if (isReplying || (chat.topics && !chat.topics[GENERAL_TOPIC_ID]?.isClosed)) return undefined;
|
||||||
return lang('lng_forum_replies_only');
|
return lang('lng_forum_replies_only');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1458,9 +1458,7 @@ export interface ActionPayloads {
|
|||||||
noForumTopicPanel?: boolean;
|
noForumTopicPanel?: boolean;
|
||||||
} & WithTabId;
|
} & WithTabId;
|
||||||
|
|
||||||
focusLastMessage: ({
|
focusLastMessage: WithTabId | undefined;
|
||||||
noForumTopicPanel?: boolean;
|
|
||||||
} & WithTabId) | undefined;
|
|
||||||
setReplyingToId: {
|
setReplyingToId: {
|
||||||
messageId?: number;
|
messageId?: number;
|
||||||
} & WithTabId;
|
} & WithTabId;
|
||||||
|
|||||||
@ -76,9 +76,12 @@ const useChatContextActions = ({
|
|||||||
return compact([actionOpenInNewTab, actionPin, actionAddToFolder]);
|
return compact([actionOpenInNewTab, actionPin, actionAddToFolder]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const actionUnreadMark = chat.unreadCount || chat.hasUnreadMark
|
const actionMaskAsRead = (chat.unreadCount || chat.hasUnreadMark)
|
||||||
? { title: lang('MarkAsRead'), icon: 'readchats', handler: () => toggleChatUnread({ id: chat.id }) }
|
? { title: lang('MarkAsRead'), icon: 'readchats', handler: () => toggleChatUnread({ id: chat.id }) }
|
||||||
: { title: lang('MarkAsUnread'), icon: 'unread', handler: () => toggleChatUnread({ id: chat.id }) };
|
: undefined;
|
||||||
|
const actionMarkAsUnread = !(chat.unreadCount || chat.hasUnreadMark) && !chat.isForum
|
||||||
|
? { title: lang('MarkAsUnread'), icon: 'unread', handler: () => toggleChatUnread({ id: chat.id }) }
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const actionMute = isMuted
|
const actionMute = isMuted
|
||||||
? {
|
? {
|
||||||
@ -117,7 +120,8 @@ const useChatContextActions = ({
|
|||||||
return compact([
|
return compact([
|
||||||
actionOpenInNewTab,
|
actionOpenInNewTab,
|
||||||
actionAddToFolder,
|
actionAddToFolder,
|
||||||
actionUnreadMark,
|
actionMaskAsRead,
|
||||||
|
actionMarkAsUnread,
|
||||||
actionPin,
|
actionPin,
|
||||||
!isSelf && actionMute,
|
!isSelf && actionMute,
|
||||||
!isSelf && !isServiceNotifications && !isInFolder && actionArchive,
|
!isSelf && !isServiceNotifications && !isInFolder && actionArchive,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user