Global Search: Include archive, fix pagination (#5013)
This commit is contained in:
parent
9f6686e7c6
commit
007da552a4
@ -29,7 +29,6 @@ import type {
|
||||
import { MAIN_THREAD_ID, MESSAGE_DELETED } from '../../types';
|
||||
|
||||
import {
|
||||
ALL_FOLDER_ID,
|
||||
API_GENERAL_ID_LIMIT,
|
||||
DEBUG,
|
||||
GIF_MIME_TYPE,
|
||||
@ -1253,7 +1252,6 @@ export async function searchMessagesGlobal({
|
||||
broadcastsOnly: type === 'channels' || undefined,
|
||||
limit,
|
||||
filter,
|
||||
folderId: ALL_FOLDER_ID,
|
||||
minDate,
|
||||
maxDate,
|
||||
}));
|
||||
|
||||
@ -127,7 +127,7 @@ const AudioResults: FC<OwnProps & StateProps> = ({
|
||||
<div className="LeftSearch--content">
|
||||
<InfiniteScroll
|
||||
className="search-content documents-list custom-scroll"
|
||||
items={foundMessages}
|
||||
items={canRenderContents ? foundMessages : undefined}
|
||||
onLoadMore={handleLoadMore}
|
||||
noFastList
|
||||
>
|
||||
|
||||
@ -87,7 +87,7 @@ const BotAppResults: FC<OwnProps & StateProps> = ({
|
||||
<div ref={containerRef} className="LeftSearch--content">
|
||||
<InfiniteScroll
|
||||
className="search-content custom-scroll"
|
||||
items={filteredFoundIds}
|
||||
items={canRenderContents ? filteredFoundIds : undefined}
|
||||
onLoadMore={handleLoadMore}
|
||||
noFastList
|
||||
>
|
||||
|
||||
@ -133,7 +133,7 @@ const FileResults: FC<OwnProps & StateProps> = ({
|
||||
<div ref={containerRef} className="LeftSearch--content">
|
||||
<InfiniteScroll
|
||||
className="search-content documents-list custom-scroll"
|
||||
items={foundMessages}
|
||||
items={canRenderContents ? foundMessages : undefined}
|
||||
onLoadMore={handleLoadMore}
|
||||
noFastList
|
||||
>
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
&--content {
|
||||
padding-top: 0.5rem;
|
||||
overflow-y: auto;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
&--media {
|
||||
|
||||
@ -126,7 +126,7 @@ const LinkResults: FC<OwnProps & StateProps> = ({
|
||||
<div ref={containerRef} className="LeftSearch--content">
|
||||
<InfiniteScroll
|
||||
className="search-content documents-list custom-scroll"
|
||||
items={foundMessages}
|
||||
items={canRenderContents ? foundMessages : undefined}
|
||||
onLoadMore={handleLoadMore}
|
||||
noFastList
|
||||
>
|
||||
|
||||
@ -126,7 +126,7 @@ const MediaResults: FC<OwnProps & StateProps> = ({
|
||||
<div ref={containerRef} className="LeftSearch--content LeftSearch--media">
|
||||
<InfiniteScroll
|
||||
className={classNames}
|
||||
items={foundMessages}
|
||||
items={canRenderContents ? foundMessages : undefined}
|
||||
itemSelector={!searchQuery ? '.Media' : '.ListItem'}
|
||||
onLoadMore={handleLoadMore}
|
||||
noFastList
|
||||
|
||||
@ -89,23 +89,23 @@ addActionHandler('searchMessagesGlobal', (global, actions, payload): ActionRetur
|
||||
const {
|
||||
query, resultsByType, chatId,
|
||||
} = selectTabState(global, tabId).globalSearch;
|
||||
const offsetId = (resultsByType?.[type])?.nextOffsetId;
|
||||
const offsetRate = (resultsByType?.[type])?.nextOffsetRate;
|
||||
const offsetPeerId = (resultsByType?.[type])?.nextOffsetPeerId;
|
||||
const {
|
||||
totalCount, foundIds, nextOffsetId, nextOffsetPeerId, nextOffsetRate,
|
||||
} = resultsByType?.[type] || {};
|
||||
|
||||
// Stop loading if we have all the messages
|
||||
if (resultsByType?.[type]?.totalCount && resultsByType[type]!.totalCount! >= resultsByType[type]!.foundIds.length) {
|
||||
// Stop loading if we have all the messages or server returned 0
|
||||
if (totalCount !== undefined && (!totalCount || (foundIds && foundIds.length >= totalCount))) {
|
||||
return;
|
||||
}
|
||||
|
||||
const chat = chatId ? selectChat(global, chatId) : undefined;
|
||||
const offsetPeer = offsetPeerId ? selectChat(global, offsetPeerId) : undefined;
|
||||
const offsetPeer = nextOffsetPeerId ? selectChat(global, nextOffsetPeerId) : undefined;
|
||||
|
||||
searchMessagesGlobal(global, {
|
||||
query,
|
||||
type,
|
||||
offsetRate,
|
||||
offsetId,
|
||||
offsetRate: nextOffsetRate,
|
||||
offsetId: nextOffsetId,
|
||||
offsetPeer,
|
||||
chat,
|
||||
tabId,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user