feat: Improved search results when finding links in document editor (#1573)

* feat: Improved search results when finding links in document editor

* chore(deps): Bump RME for smoother link search
This commit is contained in:
Tom Moor
2020-09-26 11:07:49 -07:00
committed by GitHub
parent 6f1f855083
commit f1a95e5e79
6 changed files with 131 additions and 15 deletions

View File

@@ -312,12 +312,25 @@ export default class DocumentsStore extends BaseStore<Document> {
return this.fetchNamedPage("list", options);
};
@action
searchTitles = async (query: string, options: PaginationParams = {}) => {
const res = await client.get("/documents.search_titles", {
query,
...options,
});
invariant(res && res.data, "Search response should be available");
// add the documents and associated policies to the store
res.data.forEach(this.add);
this.addPolicies(res.policies);
return res.data;
};
@action
search = async (
query: string,
options: PaginationParams = {}
): Promise<SearchResult[]> => {
// $FlowFixMe
const compactedOptions = omitBy(options, (o) => !o);
const res = await client.get("/documents.search", {
...compactedOptions,
@@ -464,7 +477,7 @@ export default class DocumentsStore extends BaseStore<Document> {
{ key: "title", value: title },
{ key: "publish", value: options.publish },
{ key: "file", value: file },
].map((info) => {
].forEach((info) => {
if (typeof info.value === "string" && info.value) {
formData.append(info.key, info.value);
}