fix: Reduce loading jank on recent searches screen

This commit is contained in:
Tom Moor
2021-12-19 13:07:22 -08:00
parent 5507295a36
commit 73bc7d9f2a
4 changed files with 19 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ import { RouteComponentProps, StaticContext, withRouter } from "react-router";
import { Waypoint } from "react-waypoint";
import styled from "styled-components";
import breakpoint from "styled-components-breakpoint";
import { v4 as uuidv4 } from "uuid";
import { DateFilter as TDateFilter } from "@shared/types";
import { DEFAULT_PAGINATION_LIMIT } from "~/stores/BaseStore";
import { SearchParams } from "~/stores/DocumentsStore";
@@ -216,6 +217,14 @@ class Search extends React.Component<Props> {
try {
const results = await this.props.documents.search(this.query, params);
// Add to the searches store so this search can immediately appear in
// the recent searches list without a flash of load
this.props.searches.add({
id: uuidv4(),
query: this.query,
createdAt: new Date().toISOString(),
});
if (results.length === 0 || results.length < DEFAULT_PAGINATION_LIMIT) {
this.allowLoadMore = false;
} else {