aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents/Documents.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2022-08-30 13:55:41 -0400
committerbobzel <zzzman@gmail.com>2022-08-30 13:55:41 -0400
commit7f2556568ab635274c483d102fa4555d12e14835 (patch)
treea200eae31968fa2d2db119ddfded79042dfdcff0 /src/client/documents/Documents.ts
parent5dcf35a986bb1d9dbe6c26d0a7056ac43ceed007 (diff)
fixed loadingDocument issues with overwriting height with NaN and setting 'data' field unnecessarily and at the expense of being able to set it for replacement docs when using animation frames
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r--src/client/documents/Documents.ts34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 9446eb70c..b22e16633 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -653,7 +653,7 @@ export namespace Docs {
[
DocumentType.LOADING,
{
- layout: { view: LoadingBox, dataField: defaultDataKey },
+ layout: { view: LoadingBox, dataField: '' },
options: { _fitWidth: true, _fitHeight: true, nativeDimModifiable: true, links: '@links(self)' },
},
],
@@ -806,14 +806,15 @@ export namespace Docs {
dataProps.isPrototype = true;
dataProps.author = Doc.CurrentUserEmail;
dataProps.creationDate = new DateField();
- dataProps[`${fieldKey}-lastModified`] = new DateField();
-
- dataProps[fieldKey] = data;
-
- // so that the list of annotations is already initialised, prevents issues in addonly.
- // without this, if a doc has no annotations but the user has AddOnly privileges, they won't be able to add an annotation because they would have needed to create the field's list which they don't have permissions to do.
- dataProps[fieldKey + '-annotations'] = new List<Doc>();
- dataProps[fieldKey + '-sidebar'] = new List<Doc>();
+ if (fieldKey) {
+ dataProps[`${fieldKey}-lastModified`] = new DateField();
+ dataProps[fieldKey] = data;
+
+ // so that the list of annotations is already initialised, prevents issues in addonly.
+ // without this, if a doc has no annotations but the user has AddOnly privileges, they won't be able to add an annotation because they would have needed to create the field's list which they don't have permissions to do.
+ dataProps[fieldKey + '-annotations'] = new List<Doc>();
+ dataProps[fieldKey + '-sidebar'] = new List<Doc>();
+ }
// users placeholderDoc as proto if it exists
const dataDoc = Doc.assign(placeholderDoc ? Doc.GetProto(placeholderDoc) : Doc.MakeDelegate(proto, protoId), dataProps, undefined, true);
@@ -829,8 +830,8 @@ export namespace Docs {
let viewDoc: Doc;
// determines whether viewDoc should be created using placeholder Doc or default
if (placeholderDoc) {
- placeholderDoc._height = Number(options._height);
- placeholderDoc._width = Number(options._width);
+ placeholderDoc._height = options._height !== undefined ? Number(options._height) : undefined;
+ placeholderDoc._width = options._width !== undefined ? Number(options._width) : undefined;
viewDoc = Doc.assign(placeholderDoc, viewFirstProps, true, true);
} else {
viewDoc = Doc.assign(Doc.MakeDelegate(dataDoc, delegId), viewFirstProps, true, true);
@@ -846,6 +847,7 @@ export namespace Docs {
updateCachedAcls(dataDoc);
updateCachedAcls(viewDoc);
+
return viewDoc;
}
@@ -905,15 +907,8 @@ export namespace Docs {
export function ColorDocument(options: DocumentOptions = {}) {
return InstanceFromProto(Prototypes.get(DocumentType.COLOR), '', options);
}
-
- // Mapping of all loading docs to files, i.e. keeps track of files being uploaded in current session
- export const docsToFiles = new Map<Doc, File | string>();
-
export function LoadingDocument(file: File | string, options: DocumentOptions, ytString?: string) {
- const fileName = typeof file == 'string' ? file : file.name;
- options.title = fileName;
- const loading = InstanceFromProto(Prototypes.get(DocumentType.LOADING), fileName, { _height: 150, _width: 200, ...options });
- return loading;
+ return InstanceFromProto(Prototypes.get(DocumentType.LOADING), undefined, { _height: 150, _width: 200, title: typeof file == 'string' ? file : file.name, ...options }, undefined, '');
}
export function RTFDocument(field: RichTextField, options: DocumentOptions = {}, fieldKey: string = 'text') {
@@ -1756,6 +1751,7 @@ export namespace DocUtils {
const full = { ...options, _width: 400, title: name };
const pathname = Utils.prepend(result.accessPaths.agnostic.client);
const doc = await DocUtils.DocumentFromType(type, pathname, full, rootDoc);
+ rootDoc && (rootDoc.isLoading = undefined);
if (doc) {
const proto = Doc.GetProto(doc);
proto.text = result.rawText;