aboutsummaryrefslogtreecommitdiff
path: root/src/fields/Doc.ts
diff options
context:
space:
mode:
authoranika-ahluwalia <anika.ahluwalia@gmail.com>2020-06-16 00:23:42 -0500
committeranika-ahluwalia <anika.ahluwalia@gmail.com>2020-06-16 00:23:42 -0500
commit5a1a8b2c19bda271e6471e457fad59094c5c0449 (patch)
tree7fbec72a4dd9aa1a4d5e3d06e32470b5b1c44147 /src/fields/Doc.ts
parente2c60eaad49da3d0485b6f5f236fb0aabb84bef0 (diff)
parentaee958a85c61927970e55ede004c91a0251a9405 (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into anika_schema_view
Diffstat (limited to 'src/fields/Doc.ts')
-rw-r--r--src/fields/Doc.ts20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index a72088d04..70aa2d60b 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -100,7 +100,7 @@ export const UpdatingFromServer = Symbol("UpdatingFromServer");
const CachedUpdates = Symbol("Cached updates");
-function fetchProto(doc: Doc) {
+export function fetchProto(doc: Doc) {
if (doc.author !== Doc.CurrentUserEmail) {
const acl = Doc.Get(doc, "ACL", true);
switch (acl) {
@@ -116,21 +116,9 @@ function fetchProto(doc: Doc) {
}
}
- const proto = doc.proto;
- if (proto instanceof Promise) {
- proto.then(proto => {
- if (proto.author !== Doc.CurrentUserEmail) {
- if (proto.ACL === "ownerOnly") {
- proto[AclSym] = doc[AclSym] = AclPrivate;
- return undefined;
- } else if (proto.ACL === "readOnly") {
- proto[AclSym] = doc[AclSym] = AclReadonly;
- } else if (proto.ACL === "addOnly") {
- proto[AclSym] = doc[AclSym] = AclAddonly;
- }
- }
- });
- return proto;
+ if (doc.proto instanceof Promise) {
+ doc.proto.then(fetchProto);
+ return doc.proto;
}
}