diff options
author | bobzel <zzzman@gmail.com> | 2020-10-22 02:16:59 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2020-10-22 02:16:59 -0400 |
commit | 93ff528ebce3ac970fa7a5d299fd3bfbc2ee021e (patch) | |
tree | 10dcb47e8479abc46702d7fa674a10fc5c1e8b70 | |
parent | 4a79649904a70f5903e36b0d8d259583e597c315 (diff) |
fixed pinning multiple documents to work and be undoable.
-rw-r--r-- | src/client/views/collections/TabDocView.tsx | 15 |
1 files changed, 8 insertions, 7 deletions
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<TabDocViewProps> { /** * 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<TabDocViewProps> { 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(); } } |