diff options
author | bobzel <zzzman@gmail.com> | 2024-03-30 14:33:57 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2024-03-30 14:33:57 -0400 |
commit | a6d075f6ed10b2900ca7d900168dda19540fdcc7 (patch) | |
tree | 92da785242df5a47256593644c54fd3d305c037d /src | |
parent | 5a119164960a873423dfe70e8b3525596e63c04f (diff) |
fixed potential cycle in linkManager relatedLink. fixed anchors to videos not to be to timeline
Diffstat (limited to 'src')
-rw-r--r-- | src/client/util/LinkManager.ts | 17 | ||||
-rw-r--r-- | src/client/views/nodes/VideoBox.tsx | 9 | ||||
-rw-r--r-- | src/server/ApiManagers/SearchManager.ts | 34 |
3 files changed, 21 insertions, 39 deletions
diff --git a/src/client/util/LinkManager.ts b/src/client/util/LinkManager.ts index 608e05fe9..8972bf705 100644 --- a/src/client/util/LinkManager.ts +++ b/src/client/util/LinkManager.ts @@ -167,7 +167,8 @@ export class LinkManager { return anchor ? Array.from(anchor[DocData][DirectLinks]) : []; } // finds all links that contain the given anchor - relatedLinker = computedFn(function relatedLinker(this: any, anchor: Doc): Doc[] { + computedRelatedLinks = (anchor: Doc, processed: Doc[]): Doc[] => { + if (Doc.IsSystem(anchor)) return []; if (!anchor || anchor instanceof Promise || Doc.GetProto(anchor) instanceof Promise) { console.log('WAITING FOR DOC/PROTO IN LINKMANAGER'); return []; @@ -176,7 +177,19 @@ export class LinkManager { const dirLinks = Array.from(anchor[DocData][DirectLinks]).filter(l => Doc.GetProto(anchor) === anchor[DocData] || ['1', '2'].includes(LinkManager.anchorIndex(l, anchor) as any)); const anchorRoot = DocCast(anchor.rootDocument, anchor); // template Doc fields store annotations on the topmost root of a template (not on themselves since the template layout items are only for layout) const annos = DocListCast(anchorRoot[Doc.LayoutFieldKey(anchor) + '_annotations']); - return annos.reduce((list, anno) => [...list, ...LinkManager.Instance.relatedLinker(anno)], Array.from(dirLinks)); + return Array.from( + annos.reduce((set, anno) => { + if (!processed.includes(anno)) { + processed.push(anno); + this.computedRelatedLinks(anno, processed).forEach(link => set.add(link)); + } + return set; + }, new Set<Doc>(dirLinks)) + ); + }; + + relatedLinker = computedFn(function relatedLinker(this: any, anchor: Doc): Doc[] { + return this.computedRelatedLinks(anchor, [anchor]); }, true); // returns map of group type to anchor's links in that group type diff --git a/src/client/views/nodes/VideoBox.tsx b/src/client/views/nodes/VideoBox.tsx index d6881b973..4773a21c9 100644 --- a/src/client/views/nodes/VideoBox.tsx +++ b/src/client/views/nodes/VideoBox.tsx @@ -343,10 +343,11 @@ export class VideoBox extends ViewBoxAnnotatableComponent<FieldViewProps>() impl const timecode = Cast(this.layoutDoc._layout_currentTimecode, 'number', null); const marquee = AnchorMenu.Instance.GetAnchor?.(undefined, addAsAnnotation); if (!addAsAnnotation && marquee) marquee.backgroundColor = 'transparent'; - const anchor = addAsAnnotation - ? CollectionStackedTimeline.createAnchor(this.Document, this.dataDoc, this.annotationKey, timecode ? timecode : undefined, undefined, marquee, addAsAnnotation) || this.Document - : Docs.Create.ConfigDocument({ title: '#' + timecode, _timecodeToShow: timecode, annotationOn: this.Document }); - PresBox.pinDocView(anchor, { pinDocLayout: pinProps?.pinDocLayout, pinData: { ...(pinProps?.pinData ?? {}), temporal: true } }, this.Document); + const anchor = + addAsAnnotation && marquee + ? CollectionStackedTimeline.createAnchor(this.Document, this.dataDoc, this.annotationKey, timecode ? timecode : undefined, undefined, marquee, addAsAnnotation) || this.Document + : Docs.Create.ConfigDocument({ title: '#' + timecode, _timecodeToShow: timecode, annotationOn: this.Document }); + PresBox.pinDocView(anchor, { pinDocLayout: pinProps?.pinDocLayout, pinData: { ...(pinProps?.pinData ?? {}), temporal: true, pannable: true } }, this.Document); return anchor; }; diff --git a/src/server/ApiManagers/SearchManager.ts b/src/server/ApiManagers/SearchManager.ts index 72c01def7..92c10975f 100644 --- a/src/server/ApiManagers/SearchManager.ts +++ b/src/server/ApiManagers/SearchManager.ts @@ -1,14 +1,11 @@ import { exec } from 'child_process'; import { cyan, green, red, yellow } from 'colors'; -import * as path from 'path'; import { log_execution } from '../ActionUtilities'; -import { Database } from '../database'; import { Method } from '../RouteManager'; import RouteSubscriber from '../RouteSubscriber'; import { Search } from '../Search'; +import { Database } from '../database'; import ApiManager, { Registration } from './ApiManager'; -import { Directory, pathToDirectory } from './UploadManager'; -import { find } from 'find-in-files'; export class SearchManager extends ApiManager { protected initialize(register: Registration): void { @@ -35,35 +32,6 @@ export class SearchManager extends ApiManager { register({ method: Method.GET, - subscription: '/textsearch', - secureHandler: async ({ req, res }) => { - const q = req.query.q; - if (q === undefined) { - res.send([]); - return; - } - const resObj: { ids: string[]; numFound: number; lines: string[] } = { ids: [], numFound: 0, lines: [] }; - let results: any; - const dir = pathToDirectory(Directory.text); - try { - const regex = new RegExp(q.toString()); - results = await find({ term: q, flags: 'ig' }, dir, '.txt$'); - for (const result in results) { - resObj.ids.push(path.basename(result, '.txt').replace(/upload_/, '')); - resObj.lines.push(results[result].line); - resObj.numFound++; - } - res.send(resObj); - } catch (e) { - console.log(red('textsearch:bad RegExp' + q.toString())); - res.send([]); - return; - } - }, - }); - - register({ - method: Method.GET, subscription: '/dashsearch', secureHandler: async ({ req, res }) => { const solrQuery: any = {}; |