Mobile Search: Fix searching in forum topic opening main thread (#2695)
This commit is contained in:
parent
9cd1e8bbcc
commit
771eb6ff4e
@ -7,7 +7,12 @@ import { getActions, withGlobal } from '../../global';
|
||||
import type { ApiChat } from '../../api/types';
|
||||
|
||||
import { debounce } from '../../util/schedulers';
|
||||
import { selectCurrentTextSearch, selectCurrentChat, selectTabState } from '../../global/selectors';
|
||||
import {
|
||||
selectCurrentTextSearch,
|
||||
selectCurrentChat,
|
||||
selectTabState,
|
||||
selectCurrentMessageList,
|
||||
} from '../../global/selectors';
|
||||
import { getDayStartAt } from '../../util/dateFormat';
|
||||
|
||||
import Button from '../ui/Button';
|
||||
@ -22,6 +27,7 @@ export type OwnProps = {
|
||||
type StateProps = {
|
||||
isActive?: boolean;
|
||||
chat?: ApiChat;
|
||||
threadId?: number;
|
||||
query?: string;
|
||||
totalCount?: number;
|
||||
foundIds?: number[];
|
||||
@ -33,6 +39,7 @@ const runDebouncedForSearch = debounce((cb) => cb(), 200, false);
|
||||
const MobileSearchFooter: FC<StateProps> = ({
|
||||
isActive,
|
||||
chat,
|
||||
threadId,
|
||||
query,
|
||||
totalCount,
|
||||
foundIds,
|
||||
@ -81,12 +88,12 @@ const MobileSearchFooter: FC<StateProps> = ({
|
||||
// Focus message
|
||||
useEffect(() => {
|
||||
if (chat?.id && foundIds?.length) {
|
||||
focusMessage({ chatId: chat.id, messageId: foundIds[0] });
|
||||
focusMessage({ chatId: chat.id, messageId: foundIds[0], threadId });
|
||||
setFocusedIndex(0);
|
||||
} else {
|
||||
setFocusedIndex(-1);
|
||||
}
|
||||
}, [chat?.id, focusMessage, foundIds]);
|
||||
}, [chat?.id, focusMessage, foundIds, threadId]);
|
||||
|
||||
// Disable native up/down buttons on iOS
|
||||
useEffect(() => {
|
||||
@ -122,18 +129,18 @@ const MobileSearchFooter: FC<StateProps> = ({
|
||||
const handleUp = useCallback(() => {
|
||||
if (chat && foundIds) {
|
||||
const newFocusIndex = focusedIndex + 1;
|
||||
focusMessage({ chatId: chat.id, messageId: foundIds[newFocusIndex] });
|
||||
focusMessage({ chatId: chat.id, messageId: foundIds[newFocusIndex], threadId });
|
||||
setFocusedIndex(newFocusIndex);
|
||||
}
|
||||
}, [chat, focusedIndex, focusMessage, foundIds]);
|
||||
}, [chat, foundIds, focusedIndex, threadId]);
|
||||
|
||||
const handleDown = useCallback(() => {
|
||||
if (chat && foundIds) {
|
||||
const newFocusIndex = focusedIndex - 1;
|
||||
focusMessage({ chatId: chat.id, messageId: foundIds[newFocusIndex] });
|
||||
focusMessage({ chatId: chat.id, messageId: foundIds[newFocusIndex], threadId });
|
||||
setFocusedIndex(newFocusIndex);
|
||||
}
|
||||
}, [chat, focusedIndex, focusMessage, foundIds]);
|
||||
}, [chat, foundIds, focusedIndex, threadId]);
|
||||
|
||||
const handleCloseLocalTextSearch = useCallback(() => {
|
||||
closeLocalTextSearch();
|
||||
@ -210,12 +217,14 @@ export default memo(withGlobal<OwnProps>(
|
||||
}
|
||||
|
||||
const { query, results } = selectCurrentTextSearch(global) || {};
|
||||
const { threadId } = selectCurrentMessageList(global) || {};
|
||||
const { totalCount, foundIds } = results || {};
|
||||
|
||||
return {
|
||||
chat,
|
||||
query,
|
||||
totalCount,
|
||||
threadId,
|
||||
foundIds,
|
||||
isHistoryCalendarOpen: Boolean(selectTabState(global).historyCalendarSelectedAt),
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user