From fb918c91e9c7533868601c6d3e23687b5dccf1df Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 21 Oct 2020 23:09:41 -0400 Subject: fixed warnings. fixed pinning of multiple documents at the same time to bring up the presentation view just once. --- src/client/views/collections/TabDocView.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/client/views/collections/TabDocView.tsx') diff --git a/src/client/views/collections/TabDocView.tsx b/src/client/views/collections/TabDocView.tsx index 338b1d590..9c5f7c66e 100644 --- a/src/client/views/collections/TabDocView.tsx +++ b/src/client/views/collections/TabDocView.tsx @@ -124,7 +124,7 @@ export class TabDocView extends React.Component { **/ @undoBatch @action - public static async PinDoc(doc: Doc, unpin = false, audioRange?: boolean) { + public static PinDoc(doc: Doc, unpin = false, audioRange?: boolean) { if (unpin) console.log('TODO: Remove UNPIN from this location'); //add this new doc to props.Document const curPres = CurrentUserUtils.ActivePresentation; @@ -140,11 +140,15 @@ export class TabDocView extends React.Component { pinDoc.presEndTime = doc.duration; } if (curPres.expandBoolean) pinDoc.presExpandInlineButton = true; - const curPresDocView = DocumentManager.Instance.getDocumentView(curPres); - if (!curPresDocView) { + const dview = CollectionDockingView.Instance.props.Document; + const fieldKey = CollectionDockingView.Instance.props.fieldKey; + const sublists = DocListCast(dview[fieldKey]); + const tabs = Cast(sublists[0], Doc, null); + const tabdocs = DocListCast(tabs.data); + if (!tabdocs.includes(curPres)) { CollectionDockingView.AddSplit(curPres, "right"); } - await DocumentManager.Instance.jumpToDocument(doc, false, undefined); + DocumentManager.Instance.jumpToDocument(doc, false, undefined); } } -- cgit v1.2.3-70-g09d2 From a61527764cf7db2f7159730504dc70736219035d Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 21 Oct 2020 23:59:30 -0400 Subject: fixed dragging documents to bottom of presentation list. fixed adding to preentation list without creatinga a duplicate. --- src/client/views/collections/CollectionStackingView.tsx | 2 +- src/client/views/collections/TabDocView.tsx | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/client/views/collections/TabDocView.tsx') diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx index d490b65a8..4880d342c 100644 --- a/src/client/views/collections/CollectionStackingView.tsx +++ b/src/client/views/collections/CollectionStackingView.tsx @@ -295,7 +295,7 @@ export class CollectionStackingView extends CollectionSubView this.filteredChildren.find((fdoc, i) => ndoc === fdoc && i <= insertInd) ? off + 1 : off, 0); + const offset = newDocs.reduce((off, ndoc) => this.filteredChildren.find((fdoc, i) => ndoc === fdoc && i < insertInd) ? off + 1 : off, 0); newDocs.filter(ndoc => docs.indexOf(ndoc) !== -1).forEach(ndoc => docs.splice(docs.indexOf(ndoc), 1)); docs.splice(insertInd - offset, 0, ...newDocs); } diff --git a/src/client/views/collections/TabDocView.tsx b/src/client/views/collections/TabDocView.tsx index 9c5f7c66e..41c372faa 100644 --- a/src/client/views/collections/TabDocView.tsx +++ b/src/client/views/collections/TabDocView.tsx @@ -6,7 +6,7 @@ import { clamp } from 'lodash'; import { action, computed, IReactionDisposer, observable, reaction } from "mobx"; import { observer } from "mobx-react"; import * as ReactDOM from 'react-dom'; -import { DataSym, Doc, DocListCast, Opt } from "../../../fields/Doc"; +import { DataSym, Doc, DocListCast, Opt, DocListCastAsync } from "../../../fields/Doc"; import { Id } from '../../../fields/FieldSymbols'; import { FieldId } from "../../../fields/RefField"; import { listSpec } from '../../../fields/Schema'; @@ -144,10 +144,11 @@ export class TabDocView extends React.Component { const fieldKey = CollectionDockingView.Instance.props.fieldKey; const sublists = DocListCast(dview[fieldKey]); const tabs = Cast(sublists[0], Doc, null); - const tabdocs = DocListCast(tabs.data); - if (!tabdocs.includes(curPres)) { - CollectionDockingView.AddSplit(curPres, "right"); - } + DocListCastAsync(tabs.data).then(tabdocs => { + if (!tabdocs?.includes(curPres)) { + CollectionDockingView.AddSplit(curPres, "right"); + } + }); DocumentManager.Instance.jumpToDocument(doc, false, undefined); } } -- cgit v1.2.3-70-g09d2 From 93ff528ebce3ac970fa7a5d299fd3bfbc2ee021e Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 22 Oct 2020 02:16:59 -0400 Subject: fixed pinning multiple documents to work and be undoable. --- src/client/views/collections/TabDocView.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/client/views/collections/TabDocView.tsx') diff --git a/src/client/views/collections/TabDocView.tsx b/src/client/views/collections/TabDocView.tsx index 41c372faa..d816dea0d 100644 --- a/src/client/views/collections/TabDocView.tsx +++ b/src/client/views/collections/TabDocView.tsx @@ -122,13 +122,13 @@ export class TabDocView extends React.Component { /** * Adds a document to the presentation view **/ - @undoBatch @action - public static PinDoc(doc: Doc, unpin = false, audioRange?: boolean) { + public static async PinDoc(doc: Doc, unpin = false, audioRange?: boolean) { if (unpin) console.log('TODO: Remove UNPIN from this location'); //add this new doc to props.Document const curPres = CurrentUserUtils.ActivePresentation; if (curPres) { + const batch = UndoManager.StartBatch("pinning doc"); const pinDoc = Doc.MakeAlias(doc); pinDoc.presentationTargetDoc = doc; pinDoc.title = doc.title; @@ -144,12 +144,13 @@ export class TabDocView extends React.Component { const fieldKey = CollectionDockingView.Instance.props.fieldKey; const sublists = DocListCast(dview[fieldKey]); const tabs = Cast(sublists[0], Doc, null); - DocListCastAsync(tabs.data).then(tabdocs => { - if (!tabdocs?.includes(curPres)) { - CollectionDockingView.AddSplit(curPres, "right"); - } - }); + const tabdocs = await DocListCastAsync(tabs.data); + if (!tabdocs?.includes(curPres)) { + tabdocs?.push(curPres); // bcz: Argh! this is annoying. if multiple documents are pinned, this will get called multiple times before the presentation view is drawn. Thus it won't be in the tabdocs list and it will get created multple times. so need to explicilty add the presbox to the list of open tabs + CollectionDockingView.AddSplit(curPres, "right"); + } DocumentManager.Instance.jumpToDocument(doc, false, undefined); + batch.end(); } } -- cgit v1.2.3-70-g09d2