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