aboutsummaryrefslogtreecommitdiff
path: root/src/client/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/util')
-rw-r--r--src/client/util/CurrentUserUtils.ts15
-rw-r--r--src/client/util/DocumentManager.ts17
-rw-r--r--src/client/util/DragManager.ts10
-rw-r--r--src/client/util/SharingManager.tsx6
4 files changed, 33 insertions, 15 deletions
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index dcbeba8cd..f43b6df44 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -878,7 +878,7 @@ export class CurrentUserUtils {
// Sharing sidebar is where shared documents are contained
static async setupSharingSidebar(doc: Doc, sharingDocumentId: string, linkDatabaseId: string) {
if (doc.myLinkDatabase === undefined) {
- let linkDocs = await DocServer.GetRefField(linkDatabaseId);
+ let linkDocs = Docs.newAccount ? undefined : await DocServer.GetRefField(linkDatabaseId);
if (!linkDocs) {
linkDocs = new Doc(linkDatabaseId, true);
(linkDocs as Doc).author = Doc.CurrentUserEmail;
@@ -888,7 +888,7 @@ export class CurrentUserUtils {
doc.myLinkDatabase = new PrefetchProxy(linkDocs);
}
if (doc.mySharedDocs === undefined) {
- let sharedDocs = await DocServer.GetRefField(sharingDocumentId + "outer");
+ let sharedDocs = Docs.newAccount ? undefined : await DocServer.GetRefField(sharingDocumentId + "outer");
if (!sharedDocs) {
sharedDocs = Docs.Create.StackingDocument([], {
title: "My SharedDocs", childDropAction: "alias", system: true, contentPointerEvents: "none", childLimitHeight: 0, _yMargin: 50, _gridGap: 15,
@@ -1024,6 +1024,7 @@ export class CurrentUserUtils {
// Doc.AddDocToList(Cast(doc["template-notes"], Doc, null), "data", deleg);
// }
// });
+ setTimeout(() => DocServer.UPDATE_SERVER_CACHE(), 2500);
return doc;
}
@@ -1047,8 +1048,12 @@ export class CurrentUserUtils {
await rp.get(Utils.prepend("/getUserDocumentIds")).then(ids => {
const { userDocumentId, sharingDocumentId, linkDatabaseId } = JSON.parse(ids);
if (userDocumentId !== "guest") {
- return DocServer.GetRefField(userDocumentId).then(async field =>
- this.updateUserDocument(Doc.SetUserDoc(field instanceof Doc ? field : new Doc(userDocumentId, true)), sharingDocumentId, linkDatabaseId));
+ return DocServer.GetRefField(userDocumentId).then(async field => {
+ Docs.newAccount = !(field instanceof Doc);
+ await Docs.Prototypes.initialize();
+ const userDoc = Docs.newAccount ? new Doc(userDocumentId, true) : field as Doc;
+ return this.updateUserDocument(Doc.SetUserDoc(userDoc), sharingDocumentId, linkDatabaseId);
+ });
} else {
throw new Error("There should be a user id! Why does Dash think there isn't one?");
}
@@ -1108,7 +1113,7 @@ export class CurrentUserUtils {
const response = await fetch(upload, { method: "POST", body: formData });
const json = await response.json();
if (json !== "error") {
- const doc = await DocServer.GetRefField(json);
+ const doc = Docs.newAccount ? undefined : await DocServer.GetRefField(json);
if (doc instanceof Doc) {
setTimeout(() => SearchUtil.Search(`{!join from=id to=proto_i}id:link*`, true, {}).then(docs =>
docs.docs.forEach(d => LinkManager.Instance.addLink(d))), 2000); // need to give solr some time to update so that this query will find any link docs we've added.
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index a408e1df6..2670de7a6 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -128,19 +128,24 @@ export class DocumentManager {
}
- static addRightSplit = (doc: Doc, finished?: () => void) => {
- CollectionDockingView.AddSplit(doc, "right");
- finished?.();
+ static addView = (doc: Doc, finished?: () => void, presCollection?: Doc) => {
+ if (presCollection) {
+ const collectionDocView = DocumentManager.Instance.getDocumentView(presCollection);
+ if (collectionDocView) collectionDocView.props.addDocTab(doc, "replace");
+ } else {
+ CollectionDockingView.AddSplit(doc, "right");
+ finished?.();
+ }
}
public jumpToDocument = async (
targetDoc: Doc, // document to display
willZoom: boolean, // whether to zoom doc to take up most of screen
- createViewFunc = DocumentManager.addRightSplit, // how to create a view of the doc if it doesn't exist
+ createViewFunc = DocumentManager.addView, // how to create a view of the doc if it doesn't exist
docContext?: Doc, // context to load that should contain the target
linkDoc?: Doc, // link that's being followed
closeContextIfNotFound: boolean = false, // after opening a context where the document should be, this determines whether the context should be closed if the Doc isn't actually there
originatingDoc: Opt<Doc> = undefined, // doc that initiated the display of the target odoc
- finished?: () => void
+ finished?: () => void,
): Promise<void> => {
const getFirstDocView = DocumentManager.Instance.getFirstDocumentView;
const focusAndFinish = () => { finished?.(); return false; };
@@ -190,7 +195,7 @@ export class DocumentManager {
highlight();
} else { // otherwise try to get a view of the context of the target
const targetDocContextView = getFirstDocView(targetDocContext);
- targetDocContext._scrollY = targetDocContext._scrollPY = NumCast(targetDocContext._scrollTop, 0); // this will force PDFs to activate and load their annotations / allow scrolling
+ targetDocContext._scrollY = targetDocContext._scrollPreviewY = NumCast(targetDocContext._scrollTop, 0); // this will force PDFs to activate and load their annotations / allow scrolling
if (targetDocContextView) { // we found a context view and aren't forced to create a new one ... focus on the context first..
targetDocContext._viewTransition = "transform 500ms";
targetDocContextView.props.focus(targetDocContextView.props.Document, willZoom);
diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts
index 3a0f306f3..9e91b4f55 100644
--- a/src/client/util/DragManager.ts
+++ b/src/client/util/DragManager.ts
@@ -201,7 +201,14 @@ export namespace DragManager {
}
// drag a document and drop it (or make an alias/copy on drop)
- export function StartDocumentDrag(eles: HTMLElement[], dragData: DocumentDragData, downX: number, downY: number, options?: DragOptions) {
+ export function StartDocumentDrag(
+ eles: HTMLElement[],
+ dragData: DocumentDragData,
+ downX: number,
+ downY: number,
+ options?: DragOptions,
+ dropEvent?: () => any
+ ) {
const addAudioTag = (dropDoc: any) => {
dropDoc && !dropDoc.creationDate && (dropDoc.creationDate = new DateField);
dropDoc instanceof Doc && DocUtils.MakeLinkToActiveAudio(dropDoc);
@@ -209,6 +216,7 @@ export namespace DragManager {
};
const finishDrag = (e: DragCompleteEvent) => {
const docDragData = e.docDragData;
+ if (dropEvent) dropEvent(); // glr: optional additional function to be called - in this case with presentation trails
if (docDragData && !docDragData.droppedDocuments.length) {
docDragData.dropAction = dragData.userDropAction || dragData.dropAction;
docDragData.droppedDocuments =
diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx
index 914253e3c..2b13d2a44 100644
--- a/src/client/util/SharingManager.tsx
+++ b/src/client/util/SharingManager.tsx
@@ -140,9 +140,9 @@ export class SharingManager extends React.Component<{}> {
});
return Promise.all(evaluating).then(() => {
runInAction(() => {
- for (let i = 0; i < sharingDocs.length; i++) {
- if (!this.users.find(user => user.user.email === sharingDocs[i].user.email)) {
- this.users.push(sharingDocs[i]);
+ for (const sharer of sharingDocs) {
+ if (!this.users.find(user => user.user.email === sharer.user.email)) {
+ this.users.push(sharer);
}
}
});