diff options
author | Michael Foiani <sotech117@michaels-mbp-5.devices.brown.edu> | 2022-06-14 17:03:53 -0400 |
---|---|---|
committer | Michael Foiani <sotech117@michaels-mbp-5.devices.brown.edu> | 2022-06-14 17:03:53 -0400 |
commit | 844b84bc7440e80252b4892138c47192d4cb0cc1 (patch) | |
tree | 2935c603da8047e980d43ed136fd7d909f89cef9 /src | |
parent | f02aaa806d0dac2cd0d243b68e1942550122d266 (diff) |
got the tab to open, but can't replay the movements on the tab
Diffstat (limited to 'src')
-rw-r--r-- | src/client/util/RecordingApi.ts | 64 | ||||
-rw-r--r-- | src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx | 2 |
2 files changed, 44 insertions, 22 deletions
diff --git a/src/client/util/RecordingApi.ts b/src/client/util/RecordingApi.ts index 2b8d11818..44dc4593c 100644 --- a/src/client/util/RecordingApi.ts +++ b/src/client/util/RecordingApi.ts @@ -10,13 +10,15 @@ import { DocumentManager } from "./DocumentManager"; import { CollectionDockingView } from "../views/collections/CollectionDockingView"; import { Id } from "../../fields/FieldSymbols"; import { returnAll } from "../../Utils"; +import { ContextExclusionPlugin } from "webpack"; +import { DocServer } from "../DocServer"; type Movement = { time: number, panX: number, panY: number, scale: number, - docId: String, + docId: string, } @@ -88,20 +90,20 @@ export class RecordingApi { } // in the case where only one tab was changed (updates not across dashboards), set only one to true - private updateRecordingFFViewsFromTabs = (docList: Doc[], onlyOne = false) => { + private updateRecordingFFViewsFromTabs = (tabbedDocs: Doc[], onlyOne = false) => { if (this.recordingFFViews === null) return; // so that the size comparisons are correct, we must filter to only the FFViews const isFFView = (doc: Doc) => doc && 'viewType' in doc && doc.viewType === 'freeform'; - const tabbedFFViews = new Set<String>(); - for (const DashDoc of docList) { + const tabbedFFViews = new Set<string>(); + for (const DashDoc of tabbedDocs) { if (isFFView(DashDoc)) tabbedFFViews.add(DashDoc[Id]); } // new tab was added - need to add it if (tabbedFFViews.size > this.recordingFFViews.size) { - for (const DashDoc of docList) { + for (const DashDoc of tabbedDocs) { if (!this.recordingFFViews.has(DashDoc[Id])) { isFFView(DashDoc) && this.addRecordingFFView(DashDoc); @@ -184,10 +186,9 @@ export class RecordingApi { // update the presentation mode now that we are done tracking Doc.UserDoc().presentationMode = 'none'; } + // clear presenation data this.currentPresentation = RecordingApi.NULL_PRESENTATION - // clear isRecording - // this.tracking = false // clear absoluteStart this.absoluteStart = -1 } @@ -201,7 +202,7 @@ export class RecordingApi { } } - private trackMovements = (panX: number, panY: number, docId: String, scale: number = 0) => { + private trackMovements = (panX: number, panY: number, docId: string, scale: number = 0) => { // ensure we are recording if (!this.tracking) { console.error('[recordingApi.ts] trackMovements(): tracking is false') @@ -281,25 +282,46 @@ export class RecordingApi { let preScale = -1; const zoomAndPan = (movement: Movement) => { const { panX, panY, scale } = movement; - (scale !== -1 && preScale !== scale) && document.zoomSmoothlyAboutPt([panX, panY], scale, 0); + (scale !== 0 && preScale !== scale) && document.zoomSmoothlyAboutPt([panX, panY], scale, 0); document.Document._panX = panX; document.Document._panY = panY; preScale = scale; } - // set the first frame to be at the start of the pres - zoomAndPan(filteredMovements[0]); - - // make timers that will execute each movement at the correct replay time - this.timers = filteredMovements.map(movement => { - const timeDiff = movement.time - timeViewed * 1000 - return setTimeout(() => { - // replay the movement - zoomAndPan(movement) - // if last movement, presentation is done -> set the instance var - if (movement === filteredMovements[filteredMovements.length - 1]) RecordingApi.Instance._isPlaying = false; - }, timeDiff) + // zoomAndPan(filteredMovements[0]); + + // generate a set of all unique docIds + const docIds = new Set(filteredMovements.map(movement => movement.docId)) + // TODO: optimize only ons-first load + // TODO: make async await + // TODO: make sure the cahce still hs the id + // this will load the cache, so getCachedREfFields won't have to reach server + DocServer.GetRefFields([...docIds]).then(refFields => { + console.log('refFields', refFields) + const openTab = (docId: string) => { + const isInView = DocumentManager.Instance.getDocumentViewById(docId); + if (isInView) { return isInView; } + + const doc = DocServer.GetCachedRefField(docId); + CollectionDockingView.AddSplit(doc, 'right'); + return DocumentManager.Instance.getDocumentView(doc); + } + + // make timers that will execute each movement at the correct replay time + this.timers = filteredMovements.map(movement => { + const timeDiff = movement.time - timeViewed * 1000 + return setTimeout(() => { + // open tab if it is not already open + const view = openTab(movement.docId); + // const ffView = view.CollectionFreeFormDocumentView?.().props.CollectionFreeFormView; + console.log('dview', view, 'ffView', view?.props) + // replay the movement + zoomAndPan(movement); + // if last movement, presentation is done -> set the instance var + if (movement === filteredMovements[filteredMovements.length - 1]) RecordingApi.Instance._isPlaying = false; + }, timeDiff) + }); }) } diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index 33474bc4b..a0e0f4f8d 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -1011,7 +1011,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection // console.log('setRecordingFFView', this); // } // TODO: make this based off the specific recording FFView - // (Doc.UserDoc()?.presentationMode === 'none') && RecordingApi.Instance.setPlayFFView(this); + (Doc.UserDoc()?.presentationMode === 'none' || Doc.UserDoc()?.presentationMode === 'watching') && RecordingApi.Instance.setPlayFFView(this); // if (Doc.UserDoc()?.presentationMode === 'watching') { // RecordingApi.Instance.pauseVideoAndMovements(); // Doc.UserDoc().presentationMode = 'none'; |