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