From 86a8751ca5a66fd42d7b2b3dee56210f2ef2b62d Mon Sep 17 00:00:00 2001 From: Melissa Zhang Date: Thu, 23 Jul 2020 13:20:12 -0700 Subject: adjustments to link following/editing behavior --- src/client/apis/hypothesis/HypothesisApiUtils.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/client/apis/hypothesis') diff --git a/src/client/apis/hypothesis/HypothesisApiUtils.ts b/src/client/apis/hypothesis/HypothesisApiUtils.ts index 2bffdb530..4c9fef45c 100644 --- a/src/client/apis/hypothesis/HypothesisApiUtils.ts +++ b/src/client/apis/hypothesis/HypothesisApiUtils.ts @@ -1,5 +1,9 @@ -import { StrCast } from "../../../fields/Types"; +import { StrCast, Cast } from "../../../fields/Types"; import HypothesisAuthenticationManager from "../HypothesisAuthenticationManager"; +import { SearchUtil } from "../../util/SearchUtil"; +import { action } from "mobx"; +import { Doc } from "../../../fields/Doc"; +import { DocumentType } from "../../documents/DocumentTypes"; export namespace Hypothesis { @@ -94,4 +98,20 @@ export namespace Hypothesis { const regex = new RegExp('(?<=\:)(.*?)(?=\@)/'); return regex.exec(userid)![0]; }; + + // Return corres + export const getWebDocs = async (uri: string) => { + const results: Doc[] = []; + await SearchUtil.Search(uri, true).then(action(async (res: SearchUtil.DocSearchResult) => { + const docs = await Promise.all(res.docs.map(async doc => (await Cast(doc.extendsDoc, Doc)) || doc)); + const filteredDocs = docs.filter(doc => doc.type === DocumentType.WEB && doc.data); + + console.log("docs", docs); + console.log("FILTEREDDOCS: ", filteredDocs); + filteredDocs.forEach(doc => { + results.push(doc); + }); + })); + return results; + }; } \ No newline at end of file -- cgit v1.2.3-70-g09d2